Register Service Principal: Azure Analysis Services presents opportunities for the automation of administrative tasks including server provisioning, scale up/down, pause/resume, model management, data refresh, deployment, among others. This can leverage cloud efficiencies and helps ensure the repeatability and reliability of mission-critical systems.
Such tasks can be performed in the Azure cloud using PowerShell in unattended mode. Services such as Azure Automation exist to support these processes. They should be executed using service principals for enhanced security and ease of management. Service principals are similar to on-premises service accounts, but for Azure. They use credentials in the form of an application ID along with a password or certificate. Model permissions are assigned to service principals through role membership like normal Azure Active Directory UPN accounts.
Prerequisite
Install-Module -Name SqlServer -Force
Install-Module -Name Azure.AnalysisServices -Force
Please install the sql server libraries whether it is on your local machine/azure PowerShell https://www.powershellgallery.com/packages/SqlServer
Here is a detail step by step instruction to set it up How to Automate Processing your Azure Analysis Services Models
Service Principal
Register Service Principal support is being added to the code now, Connection string will look like this User:app:[appid];Password:cert:[thumbprint]
Instructions:
- Tenant ID can be found by clicking on the Help/question mark button, click Show diagnostics
- A .json file download will Popup. In this file you can find the tenant ID
- In the Azure Portal, open Azure Activity Directory, then choose App Registrations, click on New application registration
- Provide an application name and some URL to Register Service Principal
- After you created this new application, you need to write down the application ID. This is the appId in the sample code
- Now you need to generate a key for this app ID. Click on Keys, type in the name of the key, such as appKey, then choose when it will expire, then click Save and this will Register Service Principal.
- After you save the key, the string value is displayed. You need to copy the key and save it at a safe place, because this is the only time the key will be displayed. They key will be masked if you leave this page and come back.
6. You need to come up with the username for the service principal as “app:”+application ID+”@” +tenant ID
For example, app:4cf98e73-8888-8888-b670-d21214d833ce@72f988bf-86f1-8888-8888-2d7cd011db47
7. In SSMS, you need to add this username in the database role so it has full control on the database for Register Service Principal.
Power Shell
First you need to install the Power Shell components using the following 2 commands to do Automated Job Process In AAS
Install-Module -Name SqlServer -Force
Install-Module -Name Azure.AnalysisServices -Force
Below is a test script that you can run locally in Power Shell
PowerShell script in Azure Automation
If you want to test locally you need the following modules to be installed
Install-Module -Name SqlServer -Force
Install-Module -Name Azure.AnalysisServices -Force
When you move to Azure Automation you need to import these modules from the gallery
#Import-Module AzureRM.AnalysisServices
#Import-Module Azure.AnalysisServices
#Import-Module SqlServer
$AASAppId = "b3725d14-8761-47a6-8067-abcd"
$AASAppKey = "Ct8AQAm2ro3z+tONkY+J0Cabcd="
$TenantId = "72f988bf-86f1-41af-91ab-abcd"
$AASServerName = "asazure://southcentralus.asazure.windows.net/abcd"
$AASDatabaseName = "SharePointOnlineStan"
$PWord = ConvertTo-SecureString -String $AASAppKey -AsPlainText -Force
$Credential = New-Object -TypeName "System.Management.Automation.PSCredential" -ArgumentList $AASAppId , $PWord
$rolloutEnvironment = $AASServerName.Replace("asazure://", "").Split("/")[0]
Write-Output $Credential
Write-Output $rolloutEnvironment
#Login-AzureAsAccount
Add-AzureAnalysisServicesAccount -Credential $Credential -ServicePrincipal -TenantId $tenantId -RolloutEnvironment $rolloutEnvironment
#Invoke-ASCmd -Server $AASServerName -Database $AASDatabaseName -Query $updateDataSource
Invoke-ProcessASDatabase -Server $AASServerName -DatabaseName $AASDatabaseName -RefreshType "Full"
Write-Output "Finished!"
#Invoke-ASCmd -Server $AASServerName -Database $AASDatabaseName -Query $updateDataSource
Invoke-ProcessASDatabase -Server $AASServerName -DatabaseName $AASDatabaseName -RefreshType "Full"
Write-Output "Finished!"
Then you can place the script in Azure Automation to Automated Job Process In AAS https://azure.microsoft.com/en-us/documentation/learning-paths/automation
TSG’s
- Postman: AAS Model Refresh Using REST API
- RDCMan Scaling Is Blurry: Fix In 3 Steps (kingfishertechtips.in)
- Port Number For Analysis Services – Find Ports For SSAS? (kingfishertechtips.in)
- SMTP Server In SSRS/PBIRS |Subscribe To Email Problem/Issue (kingfishertechtips.in)
- SQL Server 2022 Download, Install, Connect Using SSMS Tool (kingfishertechtips.in)
- Creating Tabular Project & Deploy Model To Analysis Service (kingfishertechtips.in)
- Deploy Tabular Project To Azure Analysis Service – SSDT Tool (kingfishertechtips.in)
- SSRS/PBIRS – Install And Configure The Report Server On-Prem (kingfishertechtips.in)
- Could Not Load Folder Contents In Portal URLs – SSRSPBIRS (kingfishertechtips.in)
- SSRS/PBIRS – Install And Configure The Report Server On-Prem (kingfishertechtips.in)
- SQL Server 2022 Download, Install, Connect Using SSMS Tool (kingfishertechtips.in)
- Capture Fiddler Trace for Debugging the Network Traffic (kingfishertechtips.in)
- On-Premises Gateway: Configure/Map SQL DB To Power Bi (kingfishertechtips.in)
- Fixed Column/Row Header Make Visible In Any Report (kingfishertechtips.in)
- Self-Signed Certificate: Configure SSRS/PBIRS With SSL (kingfishertechtips.in)
- Create Local User Account/Local Admin User In Windows 10/11 (kingfishertechtips.in)
- Login With AAD/Domain/Microsoft Account To Azure VM’s/RDP (kingfishertechtips.in)