由网友(树上的咸鱼)分享简介:在Azure中:尝试为分配了托管标识的逻辑应用程序系统分配用于启动/停止虚拟机的角色时,我收到以下错误消息:Error: authorization.RoleAssignmentsClient#Create: Failure responding to request: StatusCode=400 -- Origin...![使用Azure API Management,Functions ,Power Apps和Logic App构建应用](https://p.xsw88.cn/allimgs/daicuo/20230903/4230.png)
在Azure中:尝试为分配了托管标识的逻辑应用程序系统分配用于启动/停止虚拟机的角色时,我收到以下错误消息:
Error: authorization.RoleAssignmentsClient#Create: Failure responding to request: StatusCode=400 -- Original Error: autorest/azure: Service returned an error. Status=400 Code="PrincipalNotFound" Message="Principal xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx does not exist in the directory xxxxx-x-x-x-xxxx."
我的假设是,当模板输出时,我没有获得正确的ID
"[reference(resourceId('Microsoft.Logic/workflows/', 'scheduledvmdown'), '2019-05-01', 'Full').Identity.tenantId]"
![使用Azure API Management,Functions ,Power Apps和Logic App构建应用](https://p.xsw88.cn/allimgs/daicuo/20230903/4230.png)
应将Terraform模板部署输出用作角色分配main_id的输入。
我使用terraform部署逻辑应用模板,如下所示:
resource "azurerm_template_deployment" "myterraformscheduledvmdown" {
name = "scheduledvmdown"
resource_group_name = "j14t23resources"
template_body = <<DEPLOY
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
...
"resources": [
{
"type": "Microsoft.Logic/workflows",
"apiVersion": "2019-05-01",
"name": "scheduledvmdown",
"location": "westus2",
"identity": {
"type": "SystemAssigned"
},
"properties":
...
],
"outputs": {
"appid": {
"type": "string",
"value": "[reference(resourceId('Microsoft.Logic/workflows/', 'scheduledvmdown'), '2019-05-01', 'Full').Identity.tenantId]"
...
DEPLOY
parameters = {
}
deployment_mode = "Incremental"
}
output "appid" {
value = "${lookup(azurerm_template_deployment.myterraformscheduledvmdown.outputs, "appid")}"
}
resource "azurerm_role_assignment" "scheduletovmdown" {
scope = azurerm_linux_virtual_machine.myterraformvm.id
role_definition_name = "Virtual Machine Contributor"
principal_id = azurerm_template_deployment.myterraformscheduledvmdown.outputs["appid"]
}
推荐答案
对,应该是principalId
,不是tenantId
:
"[reference(resourceId('Microsoft.Logic/workflows/', 'scheduledvmdown'), '2019-05-01', 'Full').Identity.principalId]"
相关推荐
最新文章