通过ARM部署为Azure Logic Apps托管身份分配terraform角色?

通过ARM部署为Azure Logic Apps托管身份分配terraform角色?,azure,terraform,azure-resource-manager,Azure,Terraform,Azure Resource Manager,在azure中:尝试为logic apps系统分配的托管标识分配用于启动/停止虚拟机的角色时,我收到以下错误消息: Error: authorization.RoleAssignmentsClient#Create: Failure responding to request: StatusCode=400 -- Original Error: autorest/azure: Service returned an error. Status=400 Code="PrincipalNotFoun

在azure中:尝试为logic apps系统分配的托管标识分配用于启动/停止虚拟机的角色时,我收到以下错误消息:

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]"  
terraform模板部署输出应用作角色分配主体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"]
}
resource“azurerm\u模板\u部署”“myterraformscheduledvmdown”{
name=“scheduledvmdown”
资源组名称=“j14t23resources”

模板体=正确,它应该是
principalId
,而不是
tenantId

"[reference(resourceId('Microsoft.Logic/workflows/', 'scheduledvmdown'), '2019-05-01', 'Full').Identity.principalId]"