简体   繁体   English

Azure 错误:从 Azure Marketplace 部署 Visual Studio Community VM 时出现 SubscriptionNotAuthorizedForImage

[英]Azure Error: SubscriptionNotAuthorizedForImage when deploying a Visual Studio Community VM from Azure Marketplace

I am trying to deploy an Azure VM based off of the "Visual Studio 2019 Latest" image.我正在尝试基于“Visual Studio 2019 Latest”图像部署 Azure VM。 Initially it had an error in the template where the version was just being called "latest".最初它在模板中有一个错误,其中版本只是被称为“最新”。 I replaced this value with the correct value that I obtained from Get-AzVMImage cmdlet.我将此值替换为从 Get-AzVMImage cmdlet 获得的正确值。 The error then went away (PlatformImageNotFound error).然后错误消失了(PlatformImageNotFound 错误)。 Now when I attempt to redeploy with the correct value in the template, it quickly errors out with: SubscriptionNotAuthorizedForImage现在,当我尝试使用模板中的正确值重新部署时,它很快就会出错:SubscriptionNotAuthorizedForImage

A google shows that this error comes from, surprise surprise, the subscription not being authorized for the image.谷歌显示这个错误来自,令人惊讶的是,订阅没有被授权用于图像。 How do I get authorization?我如何获得授权? In my subscription I have enabled resource providers to just about every one that I could imagine would be relevant, and still no dice.在我的订阅中,我已经使资源提供者能够访问我能想到的几乎所有相关的资源,但仍然没有骰子。 In the description it says that you must be a VS subscriber, but I am one.在描述中它说你必须是 VS 订户,但我是。 I have also looked to see the purchase plan variable in the Get-AzVMImage cmdlet, and it shows null (meaning that there are not any additional terms that need to be accepted before use).我还查看了 Get-AzVMImage cmdlet 中的购买计划变量,它显示 null(这意味着在使用前不需要接受任何附加条款)。

More frustratingly, nobody else seems to have had this issue.更令人沮丧的是,似乎没有其他人遇到过这个问题。 Does anyone have any recommendations?有人有什么建议吗?

{
    "error": {
        "code": "SubscriptionNotAuthorizedForImage",
        "message": "The subscription is not authorized.",
        "target": "imageReference"
    }
}

Any help would be greatly appreciated.任何帮助将不胜感激。

There are some regions which might not be available for your subscription.有些地区可能不适用于您的订阅。 If you change the region to something very common like "US East" it works.如果您将区域更改为非常常见的区域,例如“美国东部”,它会起作用。 Even if it works in a specific region, the chosen machine size might not be available.即使它适用于特定区域,所选的机器大小也可能不可用。

I had this exact problem;我有这个确切的问题; various regions didn't work - UK West, UK South, North Europe, not even US East.各个地区都不起作用——英国西部、英国南部、北欧,甚至美国东部都没有。 Eventually I tried a Windows Server machine (in US East) instead of Win10 and that worked.最终我尝试了一台 Windows Server 机器(在美国东部)而不是 Win10,并且奏效了。 Here is the image reference I used.这是我使用的图像参考。

"imageReference": {
    "publisher": "microsoftvisualstudio",
    "offer": "visualstudio2019",
    "sku": "vs-2019-ent-ws2019",
    "version": "latest"
}

I'm not totally clear on what was causing this error for me, but there may be a few reasons for this.我不完全清楚是什么导致了这个错误,但可能有几个原因。 Worth checking:值得检查:

  1. Image is not available in your chosen location.图片在您选择的位置不可用。
  2. You're using an MSDN or other restricted type of subscription.您使用的是 MSDN 或其他受限类型的订阅。
  3. The image you're trying to deploy is designed for Hyper-V Gen 1, but your VM Size only supports Gen 2.您尝试部署的映像专为 Hyper-V Gen 1 而设计,但您的 VM 大小仅支持 Gen 2。

I was getting the OPs error and firstly switched from an MSDN subscription to an EA subscription, which resulted in a different error, pertaining to the Hyper-V generation.我遇到了 OPs 错误,首先从 MSDN 订阅切换到 EA 订阅,这导致了一个不同的错误,与 Hyper-V 一代有关。

Sometimes it can be very hard to find specific images in the Portal.有时很难在门户中找到特定图像。 Some images don't even exist in the Portal and even if you do find the image, the UI seems to use version = latest and that doesn't work for all images.有些图像甚至不存在于门户中,即使您确实找到了图像,用户界面似乎使用的是version = latest ,但这并不适用于所有图像。

There are four parts to specifying the image.指定图像有四个部分。 Often the version is overlooked.通常会忽略version There is also something called a URN which concatenates these with a : .还有一种叫做 URN 的东西,它将这些与:连接起来。 See here , however, I have never used this in ARM JSON, Terraform or PowerShell. Maybe something for Bicep or AzCLI.但是,请参阅此处,我从未在 ARM、JSON、Terraform 或 PowerShell 中使用过它。也许是 Bicep 或 AzCLI 的东西。

  1. Publisher出版商
  2. Offer提供
  3. Sku斯库
  4. Version版本

Standard Windows OS images are fairly easy, so I'll use a harder one to find to demonstrate: Microsoft SQL Server 2014, SP2, Enterprise .标准 Windows 操作系统映像相当简单,因此我将使用一个更难找到的映像来演示: Microsoft SQL Server 2014, SP2, Enterprise I couldn't find this exact image in the portal.我在门户中找不到这张确切的图片。

1. List publishers for uksouth region: 1.列出uksouth地区的出版商:

# It's a safe bet the image is published by Microsoft
$Location = "uksouth"

Get-AzVmImagePublisher -Location $Location | Where-Object{$_.PublisherName -like "*Microsoft*"}

This returns ~411 publishers with Microsoft in the name.这将返回 ~411 个名称中带有Microsoft的发布者。 The best contender is MicrosoftSQLServer .最好的竞争者是MicrosoftSQLServer

2. List offers for MicrosoftSQLServer : 2. 列出MicrosoftSQLServer的报价:

$Location = "uksouth"
$Publisher = "MicrosoftSQLServer"

Get-AzVmImageOffer -Location $Location -PublisherName $Publisher

This whittles it down to ~34 SQL-related images.这将它减少到大约 34 个与 SQL 相关的图像。 To make it a little clearer, I'll add a filter:为了让它更清楚一点,我将添加一个过滤器:

Get-AzVmImageOffer -Location $Location -PublisherName $Publisher | Where-Object{$_.Offer -like "*2014*"}

I now have 4 possible images:我现在有 4 个可能的图像: 图片结果

3. Get Image SKUs: 3. 获取图片 SKU:

$Location = "uksouth"
$Publisher = "MicrosoftSQLServer"
$Offer = "SQL2014SP2-WS2012R2-BYOL"

Get-AzVMImageSku -Location $Location -PublisherName $Publisher -Offer $Offer

This returns 2 possible options:这将返回 2 个可能的选项: 可能的 SKU Surely, this means the image is available.当然,这意味着图像可用。 Why would Microsoft list an image that isn't actually deployable?为什么 Microsoft 会列出一个实际上不可部署的映像? So why do we get the error:那么为什么我们会得到错误:

The platform image 'MicrosoftSqlServer:SQL2014SP2-WS2012R2-BYOL:Enterprise:latest' is not available. 
Verify that all fields in the storage profile are correct.
For more details about storage profile information, please refer to https://aka.ms/storageprofile ErrorCode: PlatformImageNotFound ErrorMessage: 
The platform image 'MicrosoftSqlServer:SQL2014SP2-WS2012R2-BYOL:Enterprise:latest' is not available. Verify that all fields in the storage profile are correct. 
For more details about storage profile information, please refer to
https://aka.ms/storageprofile ErrorTarget: imageReference StatusCode: 404 ReasonPhrase: 
Not Found OperationID : cea13334-878b-49ad-8934-ff75ccdbf623

The clue is in the URN : MicrosoftSqlServer:SQL2014SP2-WS2012R2-BYOL:Enterprise:latest And what I have found to be the problem: latest线索在URN中: MicrosoftSqlServer:SQL2014SP2-WS2012R2-BYOL:Enterprise:latest而我发现的问题是: latest

4. Get the image version: 4.获取镜像版本:

Armed with the Publisher , Offer and Sku , we can find the available versions.有了PublisherOfferSku ,我们就可以找到可用的版本。

$Location = "uksouth"
$Publisher = "MicrosoftSQLServer"
$Offer = "SQL2014SP2-WS2012R2-BYOL"
$Sku = "Enterprise"

Get-AzVMImage -Location $Location -PublisherName $Publisher -Offer $Offer -Skus $Sku

This results in several versions:这导致了几个版本: 图像版本 I am not 100% sure what format the version number follows.我不是 100% 确定版本号遵循什么格式。 It seems to be a timestamp.这似乎是一个时间戳。 I assume the last one in the list is the "latest".我假设列表中的最后一个是“最新的”。 Note, none of them shows as latest , however, this is true for images where version = latest is known to work and not surprising.请注意,它们都没有显示为latest ,但是,对于已知version = latest有效且不足为奇的图像,这是正确的。

More information can be gleaned by adding -Version to the last cmdlet:可以通过将-Version添加到最后一个 cmdlet 来收集更多信息:

$Location = "uksouth"
$Publisher = "MicrosoftSQLServer"
$Offer = "SQL2014SP2-WS2012R2-BYOL"
$Sku = "Enterprise"
$Version = "12.21.210914"

Get-AzVMImage -Location $Location -PublisherName $Publisher -Offer $Offer -Skus $Sku -Version $Version

Resulting in the following:结果如下: 完整图像细节

Note The PurchasePlan is null , but this may be a gotcha for non-Microsoft images where an additional cost is incurred and one has to accept the vendor's T&C's.请注意PurchasePlannull ,但这可能是非 Microsoft 图像的陷阱,在这种情况下会产生额外费用并且必须接受供应商的 T&C。 See here .这里

In this example, HyperVGeneration = v1 .在此示例中, HyperVGeneration = v1 Be aware that some VM sizes do not support Gen 1. The error is fairly obvious for this though:请注意,某些 VM 大小不支持 Gen 1。不过,此错误相当明显:

The selected VM size 'Standard_DC4s_v2' cannot boot Hypervisor Generation '1'. If this was a Create operation please check that the Hypervisor Generation of the
Image matches the Hypervisor Generation of the selected VM Size. If this was an Update operation please select a Hypervisor Generation '1' VM Size. ErrorCode:
BadRequest ErrorMessage: The selected VM size 'Standard_DC4s_v2' cannot boot Hypervisor Generation '1'. If this was a Create operation please check that the
Hypervisor Generation of the Image matches the Hypervisor Generation of the selected VM Size. If this was an Update operation please select a Hypervisor
Generation '1' VM Size. ErrorTarget:  StatusCode: 400 ReasonPhrase: Bad Request OperationID : 06f9c9a6-c9bb-4c83-87aa-9d1b7392a171

5. Deploy the image: 5. 部署镜像:

I'm not going to list all the cmdlets for deploying a VM, but the main one for image selection is:我不打算列出用于部署 VM 的所有 cmdlet,但用于映像选择的主要命令是:

$Location = "uksouth"
$Publisher = "MicrosoftSQLServer"
$Offer = "SQL2014SP2-WS2012R2-BYOL"
$Sku = "Enterprise"
$Version = "12.21.210914"

Set-AzVMSourceImage -VM $oVM -PublisherName $Publisher -Offer $Offer -Skus $Sku -Version $Version

Finally, the deployed VM:最后,部署的虚拟机:

在此处输入图像描述

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

相关问题 部署新的 Azure VM 时,如何从自定义 PS 模块运行 PowerShell cmdlet? - How to run PowerShell cmdlets from custom PS modules when deploying a new Azure VM? 将 WebJob 部署到 Azure 时出错? - Getting error when deploying WebJob to Azure? Azure Function 从 Azure devops 管道部署时无法访问运行时 - Azure Function Runtime Unreachable when deploying from Azure devops pipeline azure 中的 visual studio kube.netes 项目 503 错误 - visual studio kubernetes project 503 error in azure 从 Azure 中的现有 VM 构建类似的 VM - Build a similar VM from an existing VM in Azure 部署Laravel到Azure时宕机 - Downtime when deploying Laravel to Azure Azure 使用 Visual Studio 调试时不支持 Application Insights AAD 身份验证 - Azure Application Insights AAD authentication not supported when debbuging with Visual Studio 从 Azure VM 检索主机名 - retrieve the Hostname from an Azure VM 出现错误:使用 Azure DEVOPS 部署时无法获取 Azure 的访问令牌 - Getting Error: Could not fetch access token for Azure when deploying using Azure DEVOPS 在 Azure 上使用 Terraform 部署具有托管标识的 VM 失败 - Deploying a VM with managed identity using Terraform on Azure fails
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM