I have this Azure Powershell script that successfully backs up an Azure SQL database to Azure Blob.
In its current form, I need to log in through AD.
Now I need to implement this script to execute through Azure Function at certain intervals.
The first fragment of the script:
$subscriptionId = "YOUR AZURE SUBSCRIPTION ID"
Login-AzureRmAccount
Set-AzureRmContext -SubscriptionId $subscriptionId
Therefore, I do not need to use Login-AzureRmAccount, but replace it with a method that does not require human input.
I found this link:
https://cmatskas.com/automate-login-for-azure-powershell-scripts/
- In short, the author:
- Creates an Azure AD application (with its own password)
- Creates a service principal
- Assigning Permissions to a Service Director
, .
$psCred = New-Object System.Management.Automation.PSCredential($azureAccountName, $azurePassword)
Add-AzureRmAccount -Credential $psCred -TenantId e801a3ad-3690-4aa0-a142-1d77cb360b07 -ServicePrincipal
:
, , ?
Azure AD, 1 - Azure?