azure - 使用 Add-AzureVhd 时出现错误 400

标签 azure azure-blob-storage azure-powershell vhd

我尝试将 vhd 上传到 azure(固定大小为 30GB),但上传结束后总是出现错误。

在此之前,我已导入发布设置文件,将订阅设置为默认值,并将默认存储设置为 vhds

Add-AzureVhd -Destination "https://*****.blob.core.windows.net/vhds/vm.vhd"-LocalFilePath "C:\Users\****\Desktop\vm.vhd" 正在计算文件 C:\Users\****\Desktop\vm.vhd 的 MD5 哈希值。 MD5哈希计算完成。 操作已用时间:00:02:59 创建大小为 32212255232 的新页面 blob... Add-AzureVhd:远程服务器返回错误:(400) 错误请求。 行:1 字符:1 + 添加-AzureVhd -目标“https://*****.blob.core.windows.net/vhds ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~ + 类别信息:未指定:(:) [Add-AzureVhd],StorageException +FullyQualifiedErrorId:Microsoft.WindowsAzure.Storage.StorageException,Microsoft.WindowsAzure.Commands.ServiceM 管理.StorageServices.AddAzureVhdCommand

您知道如何解决该问题吗?

最佳答案

这里有一些解决问题的想法。我刚刚尝试了你同样的挑战,没有出现任何问题。

首先,我认为您的错误是在上传之前弹出的。因为整个过程是这样的。尝试创建新的 blob 后,您的错误似乎立即弹出。之后是一个漫长的过程,检测 VHD 的空白空间。

PS C:\Users\pkirch> Add-AzureVhd -LocalFilePath 'C:\Hyper-V\Virtual Hard Disks\test30gb.vhd' -Destination "https://webdavsvr.blob.core.windows.net/vhds/test30gb.vhd"
MD5 hash is being calculated for the file  C:\Hyper-V\Virtual Hard Disks\test30gb.vhd.
MD5 hash calculation is completed.
Elapsed time for the operation: 00:02:58
Creating new page blob of size 32212255232...
Detecting the empty data blocks in the local file.
Detecting the empty data blocks completed.
Elapsed time for upload: 00:00:00

LocalFilePath                              DestinationUri                                           
-------------                              --------------                                           
C:\Hyper-V\Virtual Hard Disks\test30gb.vhd https://webdavsvr.blob.core.windows.net/vhds/test30gb.vhd

不久前我发布了一个script to upload a VHD on GitHub Gist 。看看你是否错过了任何一步。主要是:

  1. 设置当前订阅。
  2. (如果您已有存储 帐户和容器,您不必创建新的)
  3. 为当前订阅设置当前存储帐户。

    # Settings

    $SubscriptionName = "Azure MSDN - pkirchner"
    $StorageAccountName = "pkteststorageaccount"
    $Container = "vhds"
    $LocalVhd = "C:\Users\pkirch\fixedvhd20mb.vhd"

    # Select my Microsoft Azure Subscription.
    Select-AzureSubscription -SubscriptionName $SubscriptionName

    # Create new storage account.
    New-AzureStorageAccount -Location "West Europe" -StorageAccountName $StorageAccountName -Type Standard_LRS

    # Create container for VHDs.
    $StorageAccountKey = Get-AzureStorageKey -StorageAccountName $StorageAccountName

    New-AzureStorageContext -StorageAccountKey $StorageAccountKey.Primary -StorageAccountName $StorageAccountName | `
    New-AzureStorageContainer -Name $Container -Permission Off

    # Add-AzureVhd needs the CurrentStorageAccountName to be set.
    Set-AzureSubscription -SubscriptionName $SubscriptionName -CurrentStorageAccountName $StorageAccountName

    # Build destination path automatically.
    $NewContainer = Get-AzureStorageContainer -Name $Container
    $VhdFile = Split-Path -Path $LocalVhd -Leaf
    $Destination = $NewContainer.CloudBlobContainer.Uri.AbsoluteUri + "/" +  $VhdFile

    # Upload VHD
    Add-AzureVhd -Destination $Destination -LocalFilePath $LocalVhd

第二,如果您没有遗漏任何步骤,我会尝试使用 Fiddler 查找错误。将 Fiddler 与 PowerShell for Azure 结合使用并不简单。这是blog post怎么做。

关于azure - 使用 Add-AzureVhd 时出现错误 400,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32444446/

相关文章:

azure - 如何阻止 Azure 资源组列表始终恢复为对特定订阅进行筛选?

azure-storage - Azure 存储资源管理器未列出所有 blob

node.js - 多部分/表单数据到 azure blob

azure - Set-AzureRmResource 抛出 api 版本错误

azure - 是否可以从基于资源管理器的 Azure VM 创建克隆/镜像?

azure - 使用 Powershell 创建 Azure Flask

azure - 由于 Microsoft.Web 资源提供程序,无法在 Azure 中创建机器人

c# - HTTP 错误 500.32 - 将独立的 .Net Core 3.1 应用程序部署到 Azure 后,ANCM 无法加载 dll

mysql - Azure Application Insights Kusto 语言按时间生成值进行汇总

xamarin.ios - 使用 xamarin 的 Azure 移动服务 Blob 存储