简体   繁体   English

如何从带有 Terraform 的不同 Azure 帐户中的 blob 创建托管磁盘?

[英]How do I create a managed disk from a blob in a different Azure account w/Terraform?

I have a.vhd saved in my Azure storage account.我的 Azure 存储帐户中保存了一个.vhd。 I have the container set to allow anonymous read and from an unauthenticated browser I can indeed download the VHD.我将容器设置为允许匿名读取,并且从未经身份验证的浏览器中我确实可以下载 VHD。

My code:我的代码:

resource "azurerm_managed_disk" "MyDisk" {
  name                 = "MyDisk"
  location             = var.location
  resource_group_name  = azurerm_resource_group.rg.name
  storage_account_type = "Standard_LRS"
  create_option        = "Copy"
 source_resource_id = "/subscriptions/.../resourceGroups/ProvisioningScripts/providers/Microsoft.Storage/storageAccounts/myvhds/blobServices/default"
source_uri = "https://....blob.core.windows.net/images/mydisk.vhd"
  disk_size_gb         = "32"

  tags = {
    environment = "staging"
  }
}

I am getting the following error when I try to apply:尝试申请时出现以下错误:

Error: Error creating/updating Managed Disk "MyDisk" (Resource Group "rg"): compute.DisksClient#CreateOrUpdate: Failure sending request: StatusCode=403 -- Original Error: Code="LinkedAuthorizationFailed" Message="The client has permission to perform action 'Microsoft.Compute/disks/beginGetAccess/action' on scope '/subscriptions/.../resourceGroups/rg/providers/Microsoft.Compute/disks/MyDisk', however the current tenant '4019...' is not authorized to access linked subscription '626c...'."错误:创建/更新托管磁盘“MyDisk”(资源组“rg”)时出错:compute.DisksClient#CreateOrUpdate:发送请求失败:StatusCode=403 -- 原始错误:Code="LinkedAuthorizationFailed" Message="客户端有权在 scope '/subscriptions/.../resourceGroups/rg/providers/Microsoft.Compute/disks/MyDisk' 上执行操作 'Microsoft.Compute/disks/beginGetAccess/action',但当前租户 '4019...' 不是授权访问链接订阅'626c ...'。”

Thank you much for your help.非常感谢您的帮助。

It's impossible to create a managed disk from a VHD file in a different Tenant directly.直接从不同租户中的 VHD 文件创建托管磁盘是不可能的。 You need to copy the VHD file to a storage account in the same tenant and same subscription, and then you can create a new managed disk from the VHD file in that subscription.您需要将 VHD 文件复制到同一租户和同一订阅中的存储帐户,然后您可以从该订阅中的 VHD 文件创建新的托管磁盘。 Of course, your account needs to have enough permissions to copy and create.当然,您的帐户需要有足够的权限才能复制和创建。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM