Automatically pause/resume and scale up/down Azure Analysis Services using AzureRM.AnalysisServices

One of the big advantages of Azure Analysis Services is the ability to pause/resume and scale up/down as needed, this will allow you to pay only for what you use and greatly reduce costs.

Azure Analysis Services team released a PowerShell module “AzureRM.AnalysisServices” with cmdlets to manage your Azure Analysis Services resources and they could be more easy to use:

  • Get-AzureRmAnalysisServicesServer – To get your server metadata and current status
  • Suspend-AzureRmAnalysisServicesServer – To suspend a server
  • Resume-AzureRmAnalysisServicesServer – To Resume a server
  • Set-AzureRmAnalysisServicesServer – To update a server, ex: change the SKU

More details here.

But this is only effective if we somehow automate this operation, it’s not feasible if someone on the team or customer is actively pausing/resuming or scaling up/down the instance

With that in mind we build a very simple PowerShell script where you configure in which time and days the Azure AS should be on and on which SKU.

Download the full script here.

The script is configured by a JSON metadata:


The above metadata will configure Azure AS to:

Days Hours SKU
Mon-Fri 8 AM to 18 PM (peak hours) S1
Mon-Fri 18 PM to 00 AM (off peak) S0
Sat-Sun 8 AM to 00 AM S0
Other Other Pause

The powershell script has the following parameters:

-resourceGroupName The name of the Azure Resource Group your Azure AS server is deployed:


-serverName The name of the Azure AS Server:


-configStr The JSON metadata config string


The path to an Azure profile stored locally using the “Save-AzureRmContext” cmdlet.

This is useful to test the script locally.



The name of Azure Connection if you want to run this script in a Azure Automation RunBook:


Probably most of you will want to run this script on an PowerShell Runbook in Azure Automation, learn how to setup the Azure Automation here.

Next you will need to register the module “AzureRM.AnalysisServices” as an Asset of your automation account:


After that just create a new PowerShell runbook:


Paste the script and remember to set the parameter -azureRunAsConnectionName:


Publish the script and create a schedule:



That’s it! You know have your Azure AS automatically pausing/resuming and scalling up/down using a configuration file you defined.

Now just lay back and measure the savings at the end of the month!


6 thoughts on “Automatically pause/resume and scale up/down Azure Analysis Services using AzureRM.AnalysisServices

  1. Hi Rui,

    Thanks for this script. I am testing it and I got the error

    The running command stopped because the preference variable “ErrorActionPreference” or common parameter is set to Stop: Unable to find an entry point named ‘GetPerAdapterInfo’ in DLL ‘iphlpapi.dll’.”

    • Hi Pedro, that’s a very strange error… Never seen it before.

      Seems to be some issue with the PowerShell runspace you are running.

      I’ve done some searches about this and could be related with authentication and your runbook asking for credentials.

      Please confirm that you are using the “azureRunAsConnectionName” parameter, otherwise the script is asking for credentials and raises that error.

      • Hi Rui,

        Correct I was doing wrong. I included the name of AzureRunasConnectionName and also another thing I was doing incorrectly is that I put the whole path for the server including asazure:// it I put just the instance Name is enough…

        Also note that times are UTC. One thing to improve the code it to put a local time zone converter.

        Cheers e abraco


  2. This is AMAZING! I am new to PowerShell, and have been trying to figure out a similar runbook for our Power BI Embedded Azure instance. With a little adaptation to the Power BI cmdlets, I have a great solution now! Thanks so much.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s