ARM Resource Manager Template Deployment with Azure Analysis Services

Analysis Services model can be deployed in Azure in different ways like from SSDT or by running the JSON create script from SSMS.

We can leverage the richness of template deployment in our Azure Analysis Services as well.

What is Template Deployment in Azure?

The Resource Manager template you deploy can either be a local file on your machine, or an external file that is in a repository like GitHub through the Azure Portal. The same template can be deployed in multiple environment just changing the Environment parameters.

/en-us/azure/azure-resource-manager/resource-group-template-deploy-portal /en-us/azure/azure-resource-manager/resource-group-template-deploy

 

Objective

We will focus only to create the Azure Analysis Services Instance using a template. Here we will not use the Azure portal for the deployment, whereas we will use the PowerShell command to deploy the instance and configure the backup storage.

Also, we can use the parameter files explicitly to define the parameter values as described. Here we will pass the parameters directly from the PowerShell.

Prerequisite

  1. The storage account and a resource group must have been created before executing the template.
  2. You should be the Admin of the subscription who has the access to create a resource in the Subscription.

Implementation:

  1. You need to get the storage account access key: You can follow the below screenshot:

 

PowerShell Command:

 ##Installinig AzreRm.Resources Module.
#Install-Module AzureRm.Resources
##Install-Module Azure
Get-Module -ListAvailable -Name AzureRm.Resources | Select Version

Login-AzureRmAccount

# replace with your information
$serverLocation = "West Europe"
$serverName = "backuptestserver1"
$storageAccount = "samtestblob"
$storageKey = "n1P9xnk/3x4HkaybaLYmmtOVvLHd#####################################"
$containerName="azureasbackup"
$RGName = "RGSamSSAS"
$TemplateFile = "C:\temp\AzureASwBackup.json"
$skuTier="Development"
$skuName="D1"

$asAdmin ="xxxx@microsoft.com"

##Adding 99 years. Please note that if we don’t specify any expiry time, it will by
##default take one hour. After one hour you might not be able to take the backup.
$starttime = Get-Date
$endtime= $starttime.AddYears(99)

$storageaccountContext = New-AzureStorageContext -StorageAccountName $storageAccount -StorageAccountKey $storageKey
$containerSASURI = New-AzureStorageContainerSASToken -Name $containerName -Permission rwdl -FullUri -Context $storageaccountContext -StartTime $starttime -ExpiryTime $endtime
$parameters = @{}
$parameters.Add("serverName", $serverName)
$parameters.Add("serverLocation",$serverLocation)
$parameters.Add(“asAdmin”, $asAdmin)
$parameters.Add("skuName", $skuName)
$parameters.Add("skuTier",$skuTier)

# using SAS token
$parameters.Add(“storageContainerURI”, $containerSASURI)

New-AzureRmResourceGroupDeployment -ResourceGroupName $RGName -TemplateFile $TemplateFile -TemplateParameterObject $parameters -Verbose

 

AzureASwBackup.JSON.

Reference Document: /en-us/azure/templates/microsoft.analysisservices/servers

 {
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "serverName": {
      "type": "string",
      "defaultValue": "BackupTestServer"
    },
    "serverLocation": {
      "type": "string",
      "defaultValue": "West Europe"
    },
    "storageContainerURI": {
      "type": "string",
      "defaultValue": ""
    },
    "asAdmin": {
      "type": "string",
      "defaultValue": "sapa@microsoft.com"
    },
    "skuName": {
      "type": "string",
      "defaultValue": ""
    },
    "skuTier": {
      "type": "string",
      "defaultValue": " "
    }
  },

  "resources": [
    {
      "name": "[parameters('serverName')]",
      "type": "Microsoft.AnalysisServices/servers",
      "apiVersion": "2016-05-16",
      "location": "[parameters('serverLocation')]",
      "sku": {
        "name": "[parameters('skuName')]",
        "tier": "[parameters('skuTier')]"
      },
      "tags": {},
      "properties": {
        "asAdministrators": {
          "members": [
            "[parameters('asAdmin')]"
          ]
        },
        "backupBlobContainerUri": "[parameters('storageContainerURI')]"
      }
    }
  ],
  "outputs": {
  }
}

Author:      Samarendra Panda - Support Engineer, SQL Server BI Developer team, Microsoft

Reviewer:   Orsolya Gal – Support Escalation Engineer, SQL Server BI Developer team, Microsoft