简体   繁体   English

Azure CLI - az 部署组创建 - SubscriptionNotAuthorizedForImage 错误

[英]Azure CLI - az deployment group create - SubscriptionNotAuthorizedForImage Error

In Azure when deploying via 'az deployment group create' I get an error since a few days.在 Azure 中,通过“az 部署组创建”部署时,几天以来我收到一个错误。

The ressource group is created in 'West Europe' - Region资源组在“西欧” - 区域中创建

Here is my command:这是我的命令:

az deployment group create --resource-group rg-UITest-$(Build.BuildId) --template-file WorkingCopy/hook/AzureDevOps/e5_setupvm_template.json --parameters WorkingCopy/hook/AzureDevOps/e5_setupvm_parameters.json --parameters adminPassword=$env:PASSWORD_FOR_VIRTUALMACHINE

With debug Flag I get the following information使用调试标志,我得到以下信息

2021-06-01T08:49:28.2629276Z DEBUG: cli.azure.cli.core.sdk.policies: Response content:
2021-06-01T08:49:28.2630595Z DEBUG: cli.azure.cli.core.sdk.policies: {"status":"Failed","error":{"code":"DeploymentFailed","message":"At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/DeployOperations for usage details.","details":[{"code":"BadRequest","message":"{\r\n  \"error\": {\r\n    \"code\": \"SubscriptionNotAuthorizedForImage\",\r\n    \"message\": \"The subscription is not authorized.\",\r\n    \"target\": \"imageReference\"\r\n  }\r\n}"}]}}

Here is the template.json imageReference:这里是模板json图片参考:

                    "imageReference": {
                        "publisher": "MicrosoftWindowsDesktop",
                        "offer": "Windows-10",
                        "sku": "rs5-pro",
                        "version": "latest"
                    }

Just a few days ago it still worked.就在几天前,它仍然有效。 I am not sure what has changed or what the problem is.我不确定发生了什么变化或问题出在哪里。

Here the full template:这里是完整的模板:

{
    "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "location": {
            "type": "string"
        },
        "networkInterfaceName": {
            "type": "string"
        },
        "networkSecurityGroupName": {
            "type": "string"
        },
        "networkSecurityGroupRules": {
            "type": "array"
        },
        "subnetName": {
            "type": "string"
        },
        "virtualNetworkName": {
            "type": "string"
        },
        "addressPrefixes": {
            "type": "array"
        },
        "subnets": {
            "type": "array"
        },
        "publicIpAddressName": {
            "type": "string"
        },
        "publicIpAddressType": {
            "type": "string"
        },
        "publicIpAddressSku": {
            "type": "string"
        },
        "virtualMachineName": {
            "type": "string"
        },
        "virtualMachineRG": {
            "type": "string"
        },
        "osDiskType": {
            "type": "string"
        },
        "virtualMachineSize": {
            "type": "string"
        },
        "adminUsername": {
            "type": "string"
        },
        "adminPassword": {
            "type": "secureString"
        },
        "diagnosticsStorageAccountName": {
            "type": "string"
        },
        "diagnosticsStorageAccountId": {
            "type": "string"
        },
        "diagnosticsStorageAccountType": {
            "type": "string"
        },
        "diagnosticsStorageAccountKind": {
            "type": "string"
        },
        "autoShutdownStatus": {
            "type": "string"
        },
        "autoShutdownTime": {
            "type": "string"
        },
        "autoShutdownTimeZone": {
            "type": "string"
        },
        "autoShutdownNotificationStatus": {
            "type": "string"
        },
        "autoShutdownNotificationLocale": {
            "type": "string"
        },
        "autoShutdownNotificationEmail": {
            "type": "string"
        },
        "virtualNetworks_rg_scaleset4_vnet_externalid": {
            "defaultValue": "/subscriptions/fdcf7f70-e042-4c2e-aff0-c933b9a44779/resourceGroups/rg-scaleset4/providers/Microsoft.Network/virtualNetworks/rg-scaleset4-vnet",
            "type": "String"
        }
    },
    "variables": {
        "nsgId": "[resourceId(resourceGroup().name, 'Microsoft.Network/networkSecurityGroups', parameters('networkSecurityGroupName'))]",
        "vnetId": "[resourceId(resourceGroup().name,'Microsoft.Network/virtualNetworks', parameters('virtualNetworkName'))]",
        "subnetRef": "[concat(variables('vnetId'), '/subnets/', parameters('subnetName'))]"
    },
    "resources": [
        {
            "name": "[parameters('networkInterfaceName')]",
            "type": "Microsoft.Network/networkInterfaces",
            "apiVersion": "2019-07-01",
            "location": "[parameters('location')]",
            "dependsOn": [
                "[concat('Microsoft.Network/networkSecurityGroups/', parameters('networkSecurityGroupName'))]",
                "[concat('Microsoft.Network/virtualNetworks/', parameters('virtualNetworkName'))]",
                "[concat('Microsoft.Network/publicIpAddresses/', parameters('publicIpAddressName'))]"
            ],
            "properties": {
                "ipConfigurations": [
                    {
                        "name": "ipconfig1",
                        "properties": {
                            "subnet": {
                                "id": "[concat(parameters('virtualNetworks_rg_scaleset4_vnet_externalid'), '/subnets/default')]"
                            },
                            "privateIPAllocationMethod": "Dynamic",
                            "publicIpAddress": {
                                "id": "[resourceId(resourceGroup().name, 'Microsoft.Network/publicIpAddresses', parameters('publicIpAddressName'))]"
                            }
                        }
                    }
                ],
                "networkSecurityGroup": {
                    "id": "[variables('nsgId')]"
                }
            }
        },
        {
            "name": "[parameters('networkSecurityGroupName')]",
            "type": "Microsoft.Network/networkSecurityGroups",
            "apiVersion": "2019-02-01",
            "location": "[parameters('location')]",
            "properties": {
                "securityRules": "[parameters('networkSecurityGroupRules')]"
            }
        },
        {
            "name": "[parameters('virtualNetworkName')]",
            "type": "Microsoft.Network/virtualNetworks",
            "apiVersion": "2019-09-01",
            "location": "[parameters('location')]",
            "properties": {
                "addressSpace": {
                    "addressPrefixes": "[parameters('addressPrefixes')]"
                },
                "subnets": "[parameters('subnets')]"
            }
        },
        {
            "name": "[parameters('publicIpAddressName')]",
            "type": "Microsoft.Network/publicIpAddresses",
            "apiVersion": "2019-02-01",
            "location": "[parameters('location')]",
            "properties": {
                "publicIpAllocationMethod": "[parameters('publicIpAddressType')]"
            },
            "sku": {
                "name": "[parameters('publicIpAddressSku')]"
            }
        },
        {
            "name": "[parameters('virtualMachineName')]",
            "type": "Microsoft.Compute/virtualMachines",
            "apiVersion": "2019-07-01",
            "location": "[parameters('location')]",
            "dependsOn": [
                "[concat('Microsoft.Network/networkInterfaces/', parameters('networkInterfaceName'))]",
                "[concat('Microsoft.Storage/storageAccounts/', parameters('diagnosticsStorageAccountName'))]"
            ],
            "properties": {
                "hardwareProfile": {
                    "vmSize": "[parameters('virtualMachineSize')]"
                },
                "storageProfile": {
                    "osDisk": {
                        "createOption": "fromImage",
                        "managedDisk": {
                            "storageAccountType": "[parameters('osDiskType')]"
                        }
                    },
                    "imageReference": {
                        "publisher": "MicrosoftWindowsDesktop",
                        "offer": "Windows-10",
                        "sku": "rs5-pro",
                        "version": "latest"
                    }
                },
                "networkProfile": {
                    "networkInterfaces": [
                        {
                            "id": "[resourceId('Microsoft.Network/networkInterfaces', parameters('networkInterfaceName'))]"
                        }
                    ]
                },
                "osProfile": {
                    "computerName": "[parameters('virtualMachineName')]",
                    "adminUsername": "[parameters('adminUsername')]",
                    "adminPassword": "[parameters('adminPassword')]",
                    "windowsConfiguration": {
                        "enableAutomaticUpdates": true,
                        "provisionVmAgent": true,
                        "additionalUnattendContent": [
                          {
                            "passName": "oobesystem",
                            "componentName": "Microsoft-Windows-Shell-Setup",
                            "settingName": "AutoLogon",
                            "content": "[concat('<AutoLogon><Password><Value>', parameters('adminPassword'), '</Value><PlainText>true</PlainText></Password><Enabled>true</Enabled><Username>', parameters('adminUsername'), '</Username></AutoLogon>')]"
                          }
                        ]
                    }
                    
                },
                "diagnosticsProfile": {
                    "bootDiagnostics": {
                        "enabled": true,
                        "storageUri": "[concat('https://', parameters('diagnosticsStorageAccountName'), '.blob.core.windows.net/')]"
                    }
                }
            }
        },
        {
            "name": "[parameters('diagnosticsStorageAccountName')]",
            "type": "Microsoft.Storage/storageAccounts",
            "apiVersion": "2019-06-01",
            "location": "[parameters('location')]",
            "properties": {},
            "kind": "[parameters('diagnosticsStorageAccountKind')]",
            "sku": {
                "name": "[parameters('diagnosticsStorageAccountType')]"
            }
        },
        {
            "name": "[concat('shutdown-computevm-', parameters('virtualMachineName'))]",
            "type": "Microsoft.DevTestLab/schedules",
            "apiVersion": "2017-04-26-preview",
            "location": "[parameters('location')]",
            "dependsOn": [
                "[concat('Microsoft.Compute/virtualMachines/', parameters('virtualMachineName'))]"
            ],
            "properties": {
                "status": "[parameters('autoShutdownStatus')]",
                "taskType": "ComputeVmShutdownTask",
                "dailyRecurrence": {
                    "time": "[parameters('autoShutdownTime')]"
                },
                "timeZoneId": "[parameters('autoShutdownTimeZone')]",
                "targetResourceId": "[resourceId('Microsoft.Compute/virtualMachines', parameters('virtualMachineName'))]",
                "notificationSettings": {
                    "status": "[parameters('autoShutdownNotificationStatus')]",
                    "notificationLocale": "[parameters('autoShutdownNotificationLocale')]",
                    "timeInMinutes": "30",
                    "emailRecipient": "[parameters('autoShutdownNotificationEmail')]"
                }
            }
        }
    ],
    "outputs": {
        "adminUsername": {
            "type": "string",
            "value": "[parameters('adminUsername')]"
        }
    }
}

Its Normal this image is no logger available, When having this type of issue try to create it via the web interface as you will have the available SKU正常此图像没有可用的记录器,当遇到此类问题时,请尝试通过 web 界面创建它,因为您将拥有可用的 SKU

Note: the listed image via az command is not always up to date az vm image list-skus --location 'westeurope' --offer 'Windows-10' --publisher 'MicrosoftWindowsDesktop'注意:通过 az 命令列出的图像并不总是最新的az vm image list-skus --location 'westeurope' --offer 'Windows-10' --publisher 'MicrosoftWindowsDesktop'

Better use更好的使用

  source_image_reference {
    publisher = "MicrosoftWindowsDesktop"
    offer     = "Windows-10"
    version   = "latest"
    sku       = "20h2-pro"
  }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Azure CLI 2:如何在 az group deployment create 命令中提供参数? - Azure CLI 2: how to provide parameters in az group deployment create command? Azure-Az Aks CLI Azure广告错误 - Azure - az aks cli azure ad error 使用Az CLI在Azure中创建文件共享 - create file share in azure using az cli 尝试通过 az cli 创建 azure nic 接口时引发错误,v # invalid expression - Raise error, v # invalid expression when trying to create azure nic interface via az cli az cli create webapp 失败并出现 ResourceNotFound 错误 - az cli create webapp fails with ResourceNotFound error az cli 2.0 ... az webapp 创建运行时 php|7.1 错误 - az cli 2.0 … az webapp create runtime php|7.1 error 无法使用 az cli 更新 Azure 网络安全组 - Unable to update Azure Network Security Group using az cli 是否可以通过 Azure CLI“az repos policy required-reviewer create”命令添加 Azure DevOps 用户组? - Is possible to add an Azure DevOps Group of users through Azure CLI 'az repos policy required-reviewer create' command? Azure CLI任务“ az SF群集创建”因托管代理而失败 - Azure CLI task “az sf cluster create” fails with hosted agent 如何使用 Azure CLI (az ad app) 创建 scope - How to create scope using Azure CLI (az ad app)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM