0

我正在尝试使用模板部署 Azure Windows VM 并不断遇到错误code: InvalidResourceReference Resource X referenced by Resource Y was not found。资源 X 是Microsoft.Network/networkSecurityGroups(命名为“FBI”),资源 Y 是Microsoft.Network/networkInterfaces(命名为 vInterface)。

我所有需要的资源都是在此部署期间创建的,它们的依赖项在模板中设置。我做的第一件事是确认我的 FBI 资源存在,它确实做到了:

在此处输入图像描述

接下来,我确保我的 FBI 安全组在 vInterface 中被列为依赖项,以确保在创建 vInterface 之前首先创建 FBI,它是:

{
        "name": "[parameters('networkInterfaceName')]",
        "type": "Microsoft.Network/networkInterfaces",
        "apiVersion": "2018-04-01",
        "location": "[parameters('location')]",
        "dependsOn": [
            "[resourceId('Microsoft.Network/publicIPAddresses', parameters('publicIpAddressName'))]",
            "[resourceId('Microsoft.Network/networkSecurityGroups', parameters('networkSecurityGroupName'))]"
        ],
        "properties": {
            "ipConfigurations": [
                {
                    "name": "ipconfig1",
                    "properties": {
                        "subnet": {
                            "id": "[variables('subnetRef')]"
                        },
                        "privateIPAllocationMethod": "Dynamic",
                        "publicIpAddress": {
                            "id": "[resourceId('VMGroup','Microsoft.Network/publicIpAddresses', parameters('publicIpAddressName'))]"
                        }
                    }
                }
            ],
            "networkSecurityGroup": {
                "id": "[resourceId('VMGroup', 'Microsoft.Network/networkSecurityGroups', parameters('networkSecurityGroupName'))]"
            }
        }
    }

我可以确认这两个资源的位置相同。一切看起来都不错,但我不知道为什么我的 vInterface 找不到/看到我的 FBI 安全组。

以下是完整的错误消息供参考:

"error": {
"code": "InvalidResourceReference",
"message": "Resource /subscriptions/---/resourceGroups/VMGroup/providers/Microsoft.Network/networkSecurityGroups/FBI referenced by resource /subscriptions/---/resourceGroups/VMDeployment/providers/Microsoft.Network/networkInterfaces/vInterface was not found. Please make sure that the referenced resource exists, and that both resources are in the same region.",
"details": []
4

1 回答 1

1

您可能正在部署到未调用的资源组,vmgroup因此出现此错误。

您的资源 ID 被硬编码到vmgroup资源组,而不是您要部署到的资源组;将您的 resourceId() 输入更改为:

"[resourceId('Microsoft.Network/networkSecurityGroups', parameters('networkSecurityGroupName'))]"

附言。你有它在 2 个地方。

于 2018-08-02T15:21:06.180 回答