Process Azure Analysis Services objects using a Logic App part 2

Posted by

Many of my blog posts are focused on Azure cost reduction as this is essential to keep in mind when designing cloud solutions. Azure is a very cost-effective platform when it’s used in the right way, meaning you always have to consider the fact Azure is elastic and make sure your solutions scale up and down in an efficient way. Previously I showed how to autoscale Azure Analysis Services and Azure SQL Database. This time I show how to process Azure Analysis Services objects (models) in a cost-conscious way.

In my last blog post I showed how to Process Azure Analysis Services objects from Azure Data Factory v2 using a Logic App. Based on a simple example I showed how to link Azure Data Factory and Logic Apps using a webhook and how to communicate with the Azure Analysis Services (Azure AS) REST API from a Logic App. For this blog post I teamed up with a cloud integration specialist from Macaw, Stefan Conijn, to create an advanced Logic App that scales Azure AS up, processes your Azure AS objects and scales Azure AS down again. This is a common pattern as processing is a memory consuming operation, which often requires to scale up. The solution is cost-conscious because it waits for the process operation to finish after which Azure AS will be scaled down immediately.

A couple of things that are good to know when using this solution:

  • The Azure AS API is asynchronous. The only response you will get will be a 202 (accepted) status code that tells you the message arrived successfully, but that’s it. You need to poll for progress yourself. This is actually one of the advantages of using the API for processing because the traditional methods may require long-running HTTP connections. Given the nature of HTTP, it may be more reliable to avoid long-running HTTP connections from client applications as you can read in this blog post by Microsoft.
  • Logic Apps can be whitelisted on your Azure AS firewall because the outbound IP adresses of Logic Apps per Azure region are published online. This means you can keep your firewall on while processing your models using a Logic App.
  • The Logic App is by default configured to process your entire model. You can change body of the request to process specific objects (tables/partitions) as desired.


Below a screenshot of the Logic App. Every step is numbered and explained below the screenshot.Logic App

  1. The actual trigger for the Logic App. Can be triggered manually or via an HTTP POST request.
  2. A variable used to stop the ‘do until’ loop statement when upscaling of AAS is finished.
  3. HTTP PATCH request to the Azure Resource Management API to scale up the AAS instance.
  4. ‘Do until’  loop that is used to wait for the upscaling of the AAS instance to finish.
  5. A delay of 1 minute in each cycle of the ‘do until’  loop.
  6. HTTP GET request to the Azure Resource Management API to poll the status of the scaling process.
  7. Parse the result of the GET request above, so that we have easy access to the response object.
  8. Condition to check whether the scaling was finished. If so, set upscalingFinished variable to true so that the ‘do until’ loop is discontinued.
  9. HTTP POST request to the AAS REST API to trigger a full refresh of the model. This refresh happens asynchronously. The Logic App will handle this automatically by enabling “Asynchronous Pattern” on the HTTP action. This way the Logic App will only continue when the refresh is finished.
  10. HTTP PATCH request to the Azure Resource Management API to scale down the AAS instance.
  11. Parse the result of the HTTP POST request above (#9), so that we have easy access to the response object.
  12. Condition to check whether refreshing the model was completed successfully. If not, then set the status of the Logic App to ‘failed’ by using a ‘terminate’ action.


Deployment of the Logic App to your own Azure subscription is easy. First make sure you have a Service Principal (App Registration) that has the 3 permissions below.

  1. Azure Analysis Services Server administrator
  2. API Access: Azure Analysis Services (SQL Server Analysis Services Azure) – Read and Write all Models
  3. Contributor role on the Azure Analysis Services service in Azure

A step-by-step guide to create a service principal and grant permissions 1 and 2 to it can be found in my previous blog post. To add the service principal to the Contributor role you have to navigate to your Azure AS service in the Azure portal, click “Access control (IAM)” and then click “+ Add”. Now select the contributor Role and select your service principal by searching on it’s name:
MyLogicApp Contributor

Now go to my github repository and click on the “Deploy to Azure” button. After you have logged in to Azure to following form appears. Fill the required parameters, agree with the terms and click on Purchase. After the deployment go to the created resource group and click on the Logic App resource. Click on Edit and verify that it was deployed correctly. Run the Logic App!

Many thanks to Stefan Conijn!!


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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s