【问题标题】:Azure Error: SubscriptionNotAuthorizedForImage when deploying a Visual Studio Community VM from Azure MarketplaceAzure 错误:从 Azure 市场部署 Visual Studio 社区 VM 时 SubscriptionNotAuthorizedForImage
【发布时间】:2020-02-06 18:07:03
【问题描述】:

我正在尝试基于“Visual Studio 2019 最新”映像部署 Azure VM。最初它在模板中出现错误,该版本只是被称为“最新”。我用从 Get-AzVMImage cmdlet 获得的正确值替换了这个值。然后错误消失了(PlatformImageNotFound 错误)。现在,当我尝试使用模板中的正确值重新部署时,它很快就会出错:SubscriptionNotAuthorizedForImage

谷歌显示此错误来自,令人惊讶的是,订阅未获得图像授权。我如何获得授权?在我的订阅中,我已经使资源提供者能够提供几乎所有我能想象到的相关内容,但仍然没有骰子。在描述中它说您必须是 VS 订阅者,但我是其中之一。我还查看了 Get-AzVMImage cmdlet 中的购买计划变量,它显示为 null(这意味着在使用前不需要接受任何附加条款)。

更令人沮丧的是,似乎没有其他人遇到过这个问题。有人有什么建议吗?

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

任何帮助将不胜感激。

【问题讨论】:

    标签: visual-studio azure virtual-machine


    【解决方案1】:

    有些地区可能不适用于您的订阅。如果您将区域更改为“美国东部”之类的非常常见的区域,则它可以工作。即使它适用于特定区域,所选机器大小也可能不可用。

    【讨论】:

      【解决方案2】:

      我遇到了这个确切的问题;各个地区都不起作用-英国西部,英国南部,北欧,甚至美国东部。最终,我尝试了一台 Windows Server 机器(在美国东部)而不是 Win10,并且成功了。这是我使用的图片参考。

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

      【讨论】:

        【解决方案3】:

        我并不完全清楚导致此错误的原因,但可能有几个原因。值得检查:

        1. 图片在您选择的位置不可用。
        2. 您使用的是 MSDN 或其他受限订阅类型。
        3. 您尝试部署的映像是为 Hyper-V Gen 1 设计的,但您的 VM 大小仅支持 Gen 2。

        我遇到了 OPs 错误,首先从 MSDN 订阅切换到 EA 订阅,这导致了另一个与 Hyper-V 生成有关的错误。

        有时很难在门户中找到特定图像。有些图像甚至不存在于门户中,即使您确实找到了图像,UI 似乎也使用了 version = latest,而这并不适用于所有图像。

        四个部分来指定图像。 version 通常会被忽略。还有一种叫做 URN 的东西,它将这些与 : 连接起来。请参阅here,但是,我从未在 ARM JSON、Terraform 或 PowerShell 中使用过它。也许适合二头肌或 AzCLI。

        1. 出版商
        2. 报价
        3. Sku
        4. 版本

        标准 Windows 操作系统映像相当简单,因此我将使用更难找到的映像来演示:Microsoft SQL Server 2014, SP2, Enterprise。我在门户中找不到这个确切的图像。

        1。列出uksouth 区域的发布者:

        # It's a safe bet the image is published by Microsoft
        $Location = "uksouth"
        
        Get-AzVmImagePublisher -Location $Location | Where-Object{$_.PublisherName -like "*Microsoft*"}
        

        这会返回约 411 个名称中带有 Microsoft 的发布者。最佳竞争者是MicrosoftSQLServer

        2。列出MicrosoftSQLServer 的报价:

        $Location = "uksouth"
        $Publisher = "MicrosoftSQLServer"
        
        Get-AzVmImageOffer -Location $Location -PublisherName $Publisher
        
        

        这将其缩减为约 34 个与 SQL 相关的图像。为了更清楚一点,我将添加一个过滤器:

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

        我现在有 4 个可能的图像:

        3。获取图片 SKU:

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

        这将返回 2 个可能的选项: 当然,这意味着图像可用。为什么 Microsoft 会列出实际上不可部署的映像?那么为什么会出现错误:

        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
        

        线索在URNMicrosoftSqlServer:SQL2014SP2-WS2012R2-BYOL:Enterprise:latest 而我发现的问题是:latest

        4。获取镜像版本:

        配备PublisherOfferSku,我们可以找到可用的版本。

        $Location = "uksouth"
        $Publisher = "MicrosoftSQLServer"
        $Offer = "SQL2014SP2-WS2012R2-BYOL"
        $Sku = "Enterprise"
        
        Get-AzVMImage -Location $Location -PublisherName $Publisher -Offer $Offer -Skus $Sku
        

        这会产生几个版本: 我不是 100% 确定版本号遵循什么格式。这似乎是一个时间戳。我假设列表中的最后一个是“最新的”。请注意,它们都没有显示为 latest,但是,对于已知 version = latest 有效且不足为奇的图像,这是正确的。

        可以通过将-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
        

        结果如下:

        注意 PurchasePlannull,但这可能是非 Microsoft 映像的一个陷阱,其中会产生额外费用并且必须接受供应商的 T&C。见here

        在本例中,HyperVGeneration = v1。请注意,某些 VM 大小不支持第 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。部署镜像:

        我不会列出所有用于部署 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
        
        

        最后,部署的虚拟机:

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2015-04-24
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多