How to Reduce Azure Costs

reduce-azure-costs

Azure Analysis Services is Microsoft’s solution to deliver enterprise-grade business intelligence models effectively with the scale, flexibility, and management benefits of the cloudWhen Analysis Services is configured properly, it can be an affordable way to process complex data and create easy to understand insights, with minimal maintenance. Here’s how to reduce Azure costs…

Reducing the costs of Azure Analysis Services 

The most effective way to reduce costs in Azure Analysis Services is to scale down, or even disable, the account during out of office hours – such as evenings and weekends. The price of Analysis Services per hour will be the same, even if it hasn’t been used, whilst it is turned on. Unless the model is being used 24/7, there is no reason for running a high performance, high user-concurrency instance at all times. By monitoring the usage of the Analysis Services model, you can create a scale-up/scale-down schedule that can be followed automatically with the help of Azure Automation Services. 

Azure Automation is a cloud-based automation platform that can interact with Azure. It does this by running PowerShell or Python scripts inside an Azure instance. In our case, we will be using it in a PowerShell script to automatically stop Analysis Services after work hours and restart it when work begins

Preparing the Automation Account 

Head over to the Azure Portal, and sign in using an administrator account. In the search bar at the top of the portal, search for ‘Automation Account’. Click ‘Add’ and fill in the required information to create a new Azure ‘Run As’ Automation Account. Open the Automation Account and then open the modules gallery. The first module you see ‘AzureRM.profile’. Click on that, click import, and then click OK. This will import the latest version of the AzureRM.profile module, which is required for the script. You can check the progress of the import in the ‘Jobs’ menu in the Automation Account. 

AzureRMProfile

Once the job is complete, go back to the modules gallery and install the ‘AzureRM.AnalysisServices’ module. Once this is complete, the account is ready.

AzureRMAnalysisServices

Creating the script

Now that the account is set up, we can set up the Runbook that will automate the scaling of the model performance.

In the Automation Account, open the ‘Runbooks’ menu and click ‘Create a runbook’. Enter a name for the Runbook and set the type to ‘PowerShell’. The runbook should open in the Overview tab. Click ‘Edit’. In the code pane on the right, enter the code which can be downloaded at https://gallery.technet.microsoft.com/scriptcenter/Scale-and-Pause-or-Resume-54ce97a2 . Save and publish the code, and then close the edit screen.

Next, click on ‘Link to schedule’. This will bring up the ‘Schedule Runbook’ screen. Expand the Schedule tab and click ‘Create a new schedule’. Create a schedule that starts on the hour and recurs every hour. Ensure it has no expiration if you want to follow the schedule indefinitely.

Once that is set up, open the ‘Parameters and run settings’ tab. In the ENVIROMENTNAME parameter, enter the name of the environment shown just below your user account in the top right. In RESOURCEGROUPNAME, enter the name of the Resource Group that the automation account is linked to. Unless you have changed it, AZURERUNASCONNECTIONNAME can be left as default. Set SERVERNAME to the server name.

The SCALINGSCHEDULE parameter will be different depending on your needs, the below schedule will run the Analysis Services at B2 tier between 7am and 6pm on Mondays, and at B1 tier between 7am and 6pm Tue-Fri. For all times that aren’t defined, such as weekends in this case, the server will be paused (and will not cost money).

The scaling schedule can be adjusted to suit any use.

{WeekDays:[1], StartTime:”06:59:59”, StopTime:”17:59:59”, Sku: “B2”}, {WeekDays:[2,3,4,5], StartTime:”06:59:59”, StopTime:”17:59:59”, Sku: “B1”}

Click OK to apply the schedule to the runbook. The server will begin scaling automatically.

Scaling Server
[vcex_list_item responsive_font_size=”true” icon=”fa fa-linkedin-square” font_color=”#1e73be” font_size=”13″ link=”url:https%3A%2F%2Fwww.linkedin.com%2Fin%2Ftombayne%2F|||” text_align=”center”]Tom Bayne[/vcex_list_item]

This post was written by Tom Bayne, our Apprentice IT Cloud Engineer.

Need some more help or have any questions?