【问题标题】:New deployment of Azure VMSS with system assigned Managed identity fails使用系统分配的托管标识重新部署 Azure VMSS 失败
【发布时间】:2019-12-16 09:21:27
【问题描述】:

我遇到了一个问题,其中 azure vmss(已启用托管标识)的新部署由于以下错误而首次失败 -

代码:ResourceNotFound。 消息:未找到资源组“”下的资源“Microsoft.Compute/virtualMachineScaleSets/”

以下是我的arm模板的相关sn-ps -

VMSS 部分-

{
  "type": "Microsoft.Compute/virtualMachineScaleSets",
  "sku": {
    "name": "[parameters('vmNodeType0Size')]",
    "capacity": "[parameters('defaultVMScaleSetSize')]",
    "tier": "Standard"
  },
  "name": "[variables('vmNodeType0Name')]",
  "apiVersion": "[variables('vmssApiVersion')]",
  "location": "[parameters('computeLocation')]",
  "tags": {
    "resourceType": "Service Fabric",
    "clusterName": "[variables('cloudClusterName')]"
  },
  "identity": {
    "type": "systemAssigned"
  },
  "properties": {
    ...
  }
}

访问策略部分 -

{
  "type": "Microsoft.KeyVault/vaults/accessPolicies",
  "name": "[concat(variables('KeyVaultName'), '/add')]",
  "apiVersion": "2018-02-14",
  "properties": {
    "accessPolicies": [
      {
        "tenantId": "[reference(concat('Microsoft.Compute/virtualMachineScaleSets/',  variables('vmNodeType0Name'), '/providers/Microsoft.ManagedIdentity/Identities/default'), '2015-08-31-PREVIEW').tenantId]",
        "objectId": "[reference(concat('Microsoft.Compute/virtualMachineScaleSets/',  variables('vmNodeType0Name'), '/providers/Microsoft.ManagedIdentity/Identities/default'), '2015-08-31-PREVIEW').principalId]",
        "permissions": {
          "keys": [
            "get"
          ],
          "secrets": [
            "get",
            "set"
          ],
          "certificates": [
            "get"
          ]
        }
      }
    ]
  },
  "dependsOn": [
    "[concat('Microsoft.KeyVault/vaults/',  variables('KeyVaultName'))]"
  ]
}

似乎 ARM 甚至在创建 VMSS 本身之前就尝试为 VMSS 部署托管标识,因此它失败了。我发现无法为托管身份创建添加对 VMSS 创建的依赖项。后续部署成功,因为此时已经创建了 VMSS。

【问题讨论】:

    标签: azure azure-resource-manager arm-template azure-template azure-managed-identity


    【解决方案1】:

    尝试将以下内容添加到 KV 资源:

    "dependsOn": [ "[variables('vmNodeType0Name')]" ]
    

    如果这不起作用,请将对 KV 的访问策略添加到链接模板部署中,并使该部署依赖于 vmss 配置。这将始终有效。

    【讨论】:

    • 不幸的是,这对我来说是不可能的,因为我的 VM 规模集依赖于 KeyVault(将证书安装为 vaultCertificates 节点的一部分)。此外,为什么要添加对 KeyVault 的依赖,修复规模集托管标识的预配顺序?
    • 因为这不是规模集错误,这是 KV 错误,它无法等待规模集完成安装并尝试检索托管标识。此外,无论如何都可以将任何内容移动到链接模板
    • 我也尝试过这种方法,但也没有用。在这一点上,我认为这是 arm 如何为规模集部署托管标识的错误。
    • 只要使用链接模板就可以了
    猜你喜欢
    • 1970-01-01
    • 2022-10-24
    • 2021-07-27
    • 2021-04-27
    • 1970-01-01
    • 2020-09-12
    • 1970-01-01
    • 2021-07-17
    • 2020-08-09
    相关资源
    最近更新 更多