Azure 模板函数';参考';此位置不应出现异常

Azure 模板函数';参考';此位置不应出现异常,azure,azure-resource-manager,arm-template,azure-template,Azure,Azure Resource Manager,Arm Template,Azure Template,我试图使用Microsoft.Resources/deploymentScripts在我的模板中执行脚本,但我也试图在同一模板中声明取消用户分配的标识 { "type": "Microsoft.ManagedIdentity/userAssignedIdentities", "name": "scriptIdentity", "apiVersion": "2018

我试图使用Microsoft.Resources/deploymentScripts在我的模板中执行脚本,但我也试图在同一模板中声明取消用户分配的标识

{
    "type": "Microsoft.ManagedIdentity/userAssignedIdentities",
    "name": "scriptIdentity",
    "apiVersion": "2018-11-30",
    "location": "[resourceGroup().location]"
},
{
    "type": "Microsoft.Resources/deploymentScripts",
    "apiVersion": "2019-10-01-preview",
    "name": "updateAppServiceConfigMountPointScript",
    "dependsOn": [
        "[resourceId('Microsoft.Web/sites/config', parameters('appservice_name'), 'web')]",
        "[resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', 'scriptIdentity')]",
        "[resourceId('Microsoft.Storage/storageAccounts/blobServices', parameters('storageAccounts_name'), 'default')]"
    ],
    "location": "[resourceGroup().location]",
    "kind": "AzurePowerShell",
    "identity": {
        "type": "userAssigned",
        "userAssignedIdentities": {
            "principalId": "[reference(resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', 'scriptIdentity'), '2019-08-01', 'full').identity.principalId]",
            "clientId": "[reference(resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', 'scriptIdentity'), '2019-08-01', 'full').identity.clientId]"
        }
    },
    "properties": {
        "environmentVariables": [
            {
                "name": "account_name",
                "value": "[parameters('storageAccounts_name')]"
            },
            {
                "name": "app_name",
                "value": "[parameters('appservice_name')]"
            },
            {
                "name": "resource_group_name",
                "value": "[resourceGroup().name]"
            }
            
        ],
        "scriptContent": "$access_key = ((az storage account keys list --account-name $account_name) | ConvertFrom-JSON).value[0]; az webapp config storage-account add --name \\\"$app_name\\\" --resource-group \\\"$resource_group_name\\\" --custom-id \\\"frontend\\\" --storage-type \\\"AzureBlob\\\" --account-name \\\"stelckstorageaccount\\\" --share-name \\\"frontend\\\" --mount-path \\\"/home/site/wwwroot/frontend\\\" --access-key \\\"$access_key\\\"",
        "timeout": "PT1M",
        "cleanupPreference": "OnSuccess"
    }
模板在此部分失败:

"userAssignedIdentities": {
    "principalId": "[reference(resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', 'scriptIdentity'), '2019-08-01', 'full').identity.principalId]",
    "clientId": "[reference(resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', 'scriptIdentity'), '2019-08-01', 'full').identity.clientId]"
}
出现以下错误:

部署模板验证失败:“第'930'行和第'9'列的模板资源'updateAppServiceConfigMountPointScript'无效:此位置不应使用模板函数'reference'。有关用法的详细信息,请参阅。。有关用法的详细信息,请参阅“”。(代码:InvalidTemplate)

在没有引用功能的情况下,如何引用deploymentscript中分配的标识?


相关:

使用标识的resourceId,例如

"userAssignedIdentities": {
          "[resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', 'scriptIdentity')]": {}
}

有关完整示例,请参阅。

示例ARM模板中的注释
/*ttk bug*/
是什么意思,特别是因为它涉及此特定设置?它可以工作!谢谢你的回答。现在我对资源的身份权限有问题,但稍后我会解决这个问题。再次感谢!!/*ttk bug*/是一条注释,它会将其标记为错误,但它是ttk中的一个bug。Re:perms,如果您正在分配角色并在同一模板中使用它,则在您需要使用该角色时,该角色的复制可能尚未完成。我们正致力于允许deploymentScript在用户信任下运行,这将消除对MSI的需要和那个特殊问题。。。如果你看到一些不同的东西,请发回,我们可以看一看。