Azure Powershell - automating Login-AzureRmAccount AD Login - for Azure function

前端 未结 3 1028
耶瑟儿~
耶瑟儿~ 2021-01-13 06:31

I have this Azure Powershell script, which successfully backs up a SQL Azure DB to Azure Blob.

In its current form, it requires me to log in via AD.

I now n

相关标签:
3条回答
  • 2021-01-13 07:14
    1. Yes, you can use that route, or use certificate auth, or use an Azure AD user, it can login with user\password, but is considered less secure than service principal.
    2. Yes, you can use one service principal for any number of Azure Functions you would like to.
    0 讨论(0)
  • 2021-01-13 07:16

    To use Azure PowerShell in Azure Functions, you may refer to the following response in another SO thread. The example is an HTTP-Trigger, but you can modify it to use a Timer-Trigger for your use-case. Here's the link:

    Azure Function role like permissions to Stop Azure Virtual Machines

    0 讨论(0)
  • 2021-01-13 07:20

    Run PowerShell as Administrator, you need to install AzureRM in PowerShell,

    • Login to Azure

    Login-AzureRmAccount

    • Enter your Azure credentials
    • To get your subscription(s) details enter

    Get-AzureRmSubscription

    • Use the subscription id to select the subscription.

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

    • Save the AzureProfile using the below command

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

    • The json file can be used to login to Azure

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

    Put this line on top of you .ps1 file, you does not require human input.

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

    0 讨论(0)
提交回复
热议问题