Azure Powershell-自动执行Login-AzureRmAccount AD登录-用于Azure功能 [英] Azure Powershell - automating Login-AzureRmAccount AD Login - for Azure function

查看:305
本文介绍了Azure Powershell-自动执行Login-AzureRmAccount AD登录-用于Azure功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有此Azure Powershell脚本,该脚本成功将SQL Azure DB备份到Azure Blob.

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

以当前形式,它要求我通过AD登录.

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

我现在需要实现此脚本,以按特定的时间间隔通过Azure函数执行.

I now need to implement this script to execute via a Azure Function at specific intervals.

脚本的第一段:

$subscriptionId = "YOUR AZURE SUBSCRIPTION ID"

Login-AzureRmAccount
Set-AzureRmContext -SubscriptionId $subscriptionId

因此,我不需要使用Login-AzureRmAccount,而是将其替换为不需要人工输入的方法.

I thus need to not use Login-AzureRmAccount, but replace it with a method that does not require human input.

我找到了此链接:

https://cmatskas.com/automate-login-for- azure-powershell-scripts/

    简而言之,作者:
  • In short, the author:
  1. 创建一个Azure AD应用程序(使用其自己的密码)
  2. 创建服务主体
  3. 向服务主体分配权限

这是一次过的手动创建-完美.

This is a once-off manual creation - which is perfect.

作者然后登录到此新创建的应用程序

The author then logs in to this newly created application

$psCred = New-Object System.Management.Automation.PSCredential($azureAccountName, $azurePassword)


Add-AzureRmAccount -Credential $psCred -TenantId e801a3ad-3690-4aa0-a142-1d77cb360b07 -ServicePrincipal

我的问题:

  1. 这是我应该做的,以便能够使我的应用程序自动化并防止人为登录吗?

  1. Is this what I should do to be able to automate my application and prevent human login?

在步骤1中创建的此Azure AD应用程序-我可以将其用作我Azure函数的起点吗?

This Azure AD app created in step 1 - can I use this app as a starting point in my of my Azure functions?

推荐答案

  1. 是的,您可以使用该路由,也可以使用证书身份验证,或者使用Azure AD用户,它可以使用用户\密码登录,但被认为不如服务主体安全.
  2. 是的,您可以对任意数量的Azure函数使用一个服务主体.

这篇关于Azure Powershell-自动执行Login-AzureRmAccount AD登录-用于Azure功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆