在我当前的项目中,我正在使用 Azure AD 中预先创建的应用注册服务主体。我正在使用 ARM 模板创建一个 StorageV2 帐户和一些 blob 容器,然后创建一个 roleAssignment,为其中一个服务主体提供 Storage Blob Contributor 权限。ARM 模板的相关部分在本文末尾。
我发现,如果我将ObjectId普通 AD 用户(例如我自己或我的同事)的 设置为PrincipalId,则脚本可以正确运行。但是,我无法将其与服务主体一起使用。
如果我使用 Service Principal's ObjectId,则会收到以下错误:
Deployment failed. Correlation ID: 40e0c146-165a-47c0-b022-ac04781d8194. {
"error": {
"code": "PrincipalTypeNotSupported",
"message": "Principals of type Application cannot validly be used in role assignments."
}
}
Run Code Online (Sandbox Code Playgroud)
为 Azure Powershell 用户发现了一些我应该使用应用程序(客户端)ID 的建议后,我尝试了这一点,但出现以下错误(Guids 已编辑):
Deployment failed. Correlation ID: 5c725a51-230a-4d85-bb61-b2f4cdf849ff. {
"error": {
"code": "PrincipalNotFound",
"message": "Principal 9f****30 does not exist in the directory db****75."
} …Run Code Online (Sandbox Code Playgroud) azure-active-directory azure-resource-manager azure-rm-template