New-AzWebAppBackup:操作返回无效状态代码 'Bad Request'
New-AzWebAppBackup: Operation returned an invalid status code 'Bad Request'
当我尝试使用 New-AzWebAppBackup
cmdlet 在 Azure Powershell 上执行 Azure 应用服务备份时,如下所述:
https://docs.microsoft.com/en-us/powershell/module/az.websites/New-AzWebAppBackup?view=azps-3.3.0
我收到以下错误消息:
PS Azure:\> New-AzWebAppBackup -ResourceGroupName "MyResourceGroup" -Name "MyWebApp" -StorageAccountUrl "https://mystorageaccount.file.core.windows.net/"
New-AzWebAppBackup : Operation returned an invalid status code 'BadRequest'
At line:1 char:1
+ New-AzWebAppBackup -ResourceGroupName "MyResourceGroup" -Name " ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [New-AzWebAppBackup], DefaultErrorResponseException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.WebApps.Cmdlets.WebApps.NewAzureWebAppBackup
有人知道我错过了什么吗?我感谢任何建议。非常感谢。
您好,欢迎来到 Stack Overflow!
希望您的 webapp 满足能够进行备份的先决条件。备份和还原功能要求应用服务计划处于 Standard 层或 Premium 层。有关完整详细信息,请参阅 Requirements and restrictions。
我最初在执行 cmdlet 时遇到了同样的错误。但是,通过 cmdlet 传递 -debug
开关帮助我更好地理解错误:
{
"ErrorEntity": {
"ExtendedCode": "04205",
"MessageTemplate": "The provided URI is not a SAS URL for a container (it needs to be https and it has to have 2 segments).",
"Parameters": [],
"Code": "BadRequest",
"Message": "The provided URI is not a SAS URL for a container (it needs to be https and it has to have 2 segments)."
}
-StorageAccountUrl
参数需要传递 SAS URL(请参阅 this 文档)。您的存储帐户的 SAS URL 格式为:
sasurl=https://$storagename.blob.core.windows.net/$container$sastoken
要生成 SAS 令牌,运行 如下:
# Retrieve one of the Storage Account keys
$key = (Get-AzStorageAccountKey -ResourceGroupName "<rg-name>" -AccountName "<storage-account-name>").Value[0]
# Populate the Storage Account context
$ctx = New-AzureStorageContext -StorageAccountName "<storage-account-name>" -StorageAccountKey $key
# Generate the SAS token
$sastoken = New-AzureStorageContainerSASToken -Name "<container-name>" -Permission rwdl -Context $ctx
# Generate the SAS URL
$sasurl = "https://<storage-account-name>.blob.core.windows.net/<container-name>$sastoken"
# Create a backup
New-AzureRmWebAppBackup -ResourceGroupName "<rg-name>" -Name "<app-name>" -StorageAccountUrl $sas -BackupName "<backup-name>"
成功执行以上命令应该让您创建备份。响应看起来像这样:
希望对您有所帮助!
当我尝试使用 New-AzWebAppBackup
cmdlet 在 Azure Powershell 上执行 Azure 应用服务备份时,如下所述:
https://docs.microsoft.com/en-us/powershell/module/az.websites/New-AzWebAppBackup?view=azps-3.3.0
我收到以下错误消息:
PS Azure:\> New-AzWebAppBackup -ResourceGroupName "MyResourceGroup" -Name "MyWebApp" -StorageAccountUrl "https://mystorageaccount.file.core.windows.net/"
New-AzWebAppBackup : Operation returned an invalid status code 'BadRequest'
At line:1 char:1
+ New-AzWebAppBackup -ResourceGroupName "MyResourceGroup" -Name " ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [New-AzWebAppBackup], DefaultErrorResponseException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.WebApps.Cmdlets.WebApps.NewAzureWebAppBackup
有人知道我错过了什么吗?我感谢任何建议。非常感谢。
您好,欢迎来到 Stack Overflow!
希望您的 webapp 满足能够进行备份的先决条件。备份和还原功能要求应用服务计划处于 Standard 层或 Premium 层。有关完整详细信息,请参阅 Requirements and restrictions。
我最初在执行 cmdlet 时遇到了同样的错误。但是,通过 cmdlet 传递 -debug
开关帮助我更好地理解错误:
{
"ErrorEntity": {
"ExtendedCode": "04205",
"MessageTemplate": "The provided URI is not a SAS URL for a container (it needs to be https and it has to have 2 segments).",
"Parameters": [],
"Code": "BadRequest",
"Message": "The provided URI is not a SAS URL for a container (it needs to be https and it has to have 2 segments)."
}
-StorageAccountUrl
参数需要传递 SAS URL(请参阅 this 文档)。您的存储帐户的 SAS URL 格式为:
sasurl=https://$storagename.blob.core.windows.net/$container$sastoken
要生成 SAS 令牌,运行 如下:
# Retrieve one of the Storage Account keys
$key = (Get-AzStorageAccountKey -ResourceGroupName "<rg-name>" -AccountName "<storage-account-name>").Value[0]
# Populate the Storage Account context
$ctx = New-AzureStorageContext -StorageAccountName "<storage-account-name>" -StorageAccountKey $key
# Generate the SAS token
$sastoken = New-AzureStorageContainerSASToken -Name "<container-name>" -Permission rwdl -Context $ctx
# Generate the SAS URL
$sasurl = "https://<storage-account-name>.blob.core.windows.net/<container-name>$sastoken"
# Create a backup
New-AzureRmWebAppBackup -ResourceGroupName "<rg-name>" -Name "<app-name>" -StorageAccountUrl $sas -BackupName "<backup-name>"
成功执行以上命令应该让您创建备份。响应看起来像这样:
希望对您有所帮助!