Azure Analytics Database with automate Backup

337 Views Asked by At

The powershell is used to automate the backup of AAS instance. The instance have Multi-factor authentication and I think that is the problem.

enter image description here

Powershell:

 $TenantId = "TenentID"  
 $Cred = Get-AutomationPSCredential -Name 'SSASModelBackup'
 $Server = "ServerName" 
 $RolloutEnvironment = "location.asazure.windows.net" 
 $ResourceGroup = "ReourceGroupName"

 #Create Credentials to convertToSecureString
 $applicationId = "applicationId " 
 $securePassword = "securePassword " | ConvertTo-SecureString -AsPlainText -Force $Credential = New-Object
-TypeName System.Management.Automation.PSCredential -ArgumentList $applicationId, $securePassword



#Define the list of AAS databases  
$asDBs = @('database1','database2') 
Write-Output "Logging in to Azure..."   

#Add-AzureAnalysisServicesAccount -Credential $Credential -ServicePrincipal -TenantId $TenantId -RolloutEnvironment $RolloutEnvironment
ForEach($db in $asDBs)
 {
  Write-Output "Starting Backup..."
   Backup-ASDatabase `
  –backupfile ($db +"." + (Get-Date).ToString("ddMMyyyy") + ".abf") `
  –name $db `
  -server $Server `
  -Credential $Cred
  Write-Output "Backup Completed!" 
 }
1

There are 1 best solutions below

0
On

You are correct that the issue is with multi-factor authentication. Since the point of multi-factor is the require interaction with a secondary source like your phone there is no way to automate the process.

I would suggest that you look into using service principle authentication for the purpose of taking backups. By using a service principle to your server you can allow for automated tasks to run without 2-factor while minimizing the security risk.