问题描述
我正在寻找列出AAD对象的CreateOrUpDate的一个或多个示例。 我可能也会将其安排为每晚工作。 我希望将其添加到我的YAML Azure管道文件中的任务中。
我对CreateOrUpdate完全陌生,所以这里的任何帮助将不胜感激。
解决方法
您可以签出Azure cli commands来创建或更新AAD对象。文档中有很多示例:
例如,使用命令az ad app create
创建AAD应用程序:
az ad app create --display-name my-native --native-app --required-resource-accesses @manifest.json
使用命令az ad user create
创建AAD用户:
az ad user create –display-name psmith –password password –user-principal-name username@domain.onmicrosoft.com
使用命令az ad sp create-for-rbac -n "MyApp"
要在Yaml azure管道中使用上述azure cli命令,您需要使用Azure CLI Task。而且,您需要创建一个Azure Resource Manager service connection才能将您的Azure devops项目连接到Azure订阅。请参阅步骤here以创建服务连接。
- task: AzureCLI@2
displayName: Azure CLI
inputs:
azureSubscription: <Name of the Azure Resource Manager service connection>
scriptType: ps
scriptLocation: inlineScript
inlineScript: |
az --version
az account show
如果您熟悉Powershell脚本,还可以签出azure powershell commands,该文件可在Azure Powershell Task中用于创建或更新AAD对象。