Azure Powershell 命令无法将 bacpac 文件存储在 Azure blob 存储中

Azure Powershell command unable to store bacpac file in Azure blob storage

背景

我正在尝试设置一个 powershell 脚本来创建一个 .bacpac 文件并将其存储在 Azure 的 blob 存储中。我正在使用 Get-AzureRmSqldatabaseExport 命令并将其指向我的存储容器。

该命令运行,据我了解,该过程将在 运行 命令后 6 小时开始。

问题

问题是,几分钟后,我收到一条错误消息,指出 blob 存储只有读取权限,而不是读写权限。

问题

如何修改 powershell 命令以允许我写入存储容器?这与容器本身有关吗?我是否错误地使用了 blob,应该使用不同类型的存储类型?

更多信息

命令:

New-AzureRmSqlDatabaseExport -ResourceGroupName "rgnEverything" -ServerName "serverOne" -DatabaseName "databaseDev" -StorageKeyType "StorageAccessKey" -StorageKey "storageKeyOne" -StorageUri "storageUriOne" -AdministratorLogin "adminlogin" -AdministratorLoginPassword (ConvertTo-Secu
reString "password" -AsPlainText -Force)

我目前正在 运行 通过 Azure 云执行此命令 Shell

这就是 Get-AzureRmSqlDatabaseImportExportStatus returns 在 运行 命令之后的内容:

OperationStatusLink : https://management.azure.com/subscriptions/e088f9f1-aeed-401e-b8db-8bac796c43cd/resourceGroups/SweetSpot/providers/Microsoft.Sql/servers/sweetspotgolfshop/databases/SweetSpotDev/importExportOp
                      erationResults/9226c1e7-5e55-4d34-ba96-954b857c318c?api-version=2014-04-01-Preview
ErrorMessage        :
LastModifiedTime    : 3/16/2018 3:24:38 PM
QueuedTime          : 3/16/2018 3:24:35 PM
StatusMessage       : Running, Progress = 0%
Status              : InProgress

错误信息:

Get-AzureRmSqlDatabaseImportExportStatus : BadRequest: The ImportExport operation with Request Id '9226c1e7-5e55-4d34-ba96-954b857c318c' failed due to 'Error encountered during the service operation.
        Blob https://cs2e088f9f1aeedx401exb8d.blob.core.windows.net/database-backup is not writeable.
                The remote server returned an error: (404) Not Found.
                        The remote server returned an error: (404) Not Found.
'.
At line:1 char:1
+ Get-AzureRmSqlDatabaseImportExportStatus -OperationStatusLink "https: ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [Get-AzureRmSqlDatabaseImportExportStatus], CloudException
    + FullyQualifiedErrorId : Microsoft.Azure.Commands.Sql.ImportExport.Cmdlet.GetAzureSqlDatabaseImportExportStatus

存储 URI:

-StorageUri "https://cs2e088f9f1aeedx401exb8d.blob.core.windows.net/database-backup"

您将容器地址指定为目标的问题。您需要放置文件的完整所需存储 url,而不仅仅是容器路径。

所以你的 -StorageUri 参数值应该类似于

https://mystorageName.blob.core.windows.net/databasebackup/MyDbName-2018-03-16.bacpac

此外,您还需要确保在尝试备份之前容器已经存在,导出时不会为您创建它。