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:
|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|
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!