Azure Powershell - Login-Azure AutomationRmAccount AD Login - for Azure Feature

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?

+4
3
  • , auth Azure AD, \password, , .
  • , - Azure, .
+5

Azure PowerShell Azure Functions, SO. , HTTP-Trigger, , - . :

Azure, Azure

+1

PowerShell , AzureRM PowerShell,

  • Azure

Login-AzureRmAccount

  • Azure

Get-AzureRmSubscription

  • , .

Select-AzureRmSubscription -SubscriptionId xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

  • AzureProfile,

Save-AzureRmProfile -Path "C:\AzureScripts\profile.json"

  • json Azure

Select-AzureRmProfile -Path "C:\AzureScripts\profile.json"

.ps1, , .

: http://www.smartcoding.in/blog/auto-login-azure-power-shell

0

Source: https://habr.com/ru/post/1675844/


All Articles