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

标签 azure azure-blob-storage azure-powershell

背景

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

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

问题

问题是,几分钟后,我收到一条错误消息,指出 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 Cloud Shell 运行此命令

这是运行命令后 Get-AzureRmSqlDatabaseImportExportStatus 返回的内容:

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

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

关于Azure Powershell 命令无法在 Azure Blob 存储中存储 bacpac 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49323749/

相关文章:

Azure 网站从源代码管理部署因 nuget 依赖项而失败

azure - 如何检索 Azure 搜索索引的内容?

c# - 从 Azure Function 连接到 Azure Blob 存储

azure - 如何升级Azure管道中的MSbuild版本?

c# - Azure 插槽交换 : Configure WCF endpoint in Azure

azure - Windows Azure 表存储帐户的限制

c# - Azure Blob 存储列表容器和 Blob

powershell - 如何使用关联 ID 进行调试

azure - 使用 Set/New-AzureRmIotHub 时 PSOperationsMonitoringPropertie 的正确值

powershell - 通过 powershell 配置虚拟机时可以设置 MAC 地址吗?