简体   繁体   English

无法使用 Azure Cli az webapp config backup create 备份功能/Web 应用程序

[英]Unable to backup Function/Web App using Azure Cli az webapp config backup create

I am facing an issue when executing the Azure Cli command to backup my Azure App Service:我在执行 Azure CLI 命令备份我的 Azure 应用程序服务时遇到问题:

Cli Command:客户端命令:

az webapp config backup create --resource-group --webapp-name az webapp config backup create --resource-group --webapp-name
--backup-name testbackup --container-url --backup-name testbackup --container-url

I generated a new SaS key to be passed along with the command.我生成了一个新的 SaS 密钥与命令一起传递。

Is this the correct approach.这是正确的方法吗?

Cli Output:客户端 Output:

{ "backupId": 64862, "backupItemName": "testbackup", "blobName": "testbackup", "correlationId": "3e9ae4d0-9aa9-46e0-9926-53ec1ef6ef2c", "created": "2020-09-22T08:50:35.555268+00:00", "databases": null, "finishedTimeStamp": null, "id": "value", "kind": null, "lastRestoreTimeStamp": null, "location": "Central US", "log": null, "name": "testbackuppr", "resourceGroup": "RG-POC", "scheduled": false, **"sizeInBytes": 0,** "status": "Created", "storageAccountUrl": "", "type": "Microsoft.Web/sites", "websiteSizeInBytes": null }

Log Information in the Portal: Storage access failed.门户中的日志信息:存储访问失败。 The remote server returned an error: (404) Not Found.. Please delete and recreate backup schedule to mitigate.远程服务器返回错误:(404) 未找到。请删除并重新创建备份计划以缓解。

执行命令时的错误信息

Looks like something is not right with the Storage account or its access.存储帐户或其访问权限似乎有问题。 Before you execute the az webapp config backup create command, please make sure that you have a valid Storage account, a storage container and a SAS token with the appropriate expiry date.在执行az webapp config backup create命令之前,请确保你有一个有效的存储帐户、一个存储容器和一个具有适当到期日期的 SAS 令牌。 The SAS token can be generated with the az storage container generate-sas command.可以使用az storage container generate-sas命令生成 SAS 令牌。

The following script worked for me:以下脚本对我有用:

#!/bin/bash

groupname="myResourceGroup"
planname="myAppServicePlan"
webappname=mywebapp$RANDOM
storagename=mywebappstorage$RANDOM
location="WestEurope"
container="appbackup"
backupname="backup1"
expirydate=$(date -I -d "$(date) + 1 month")

# Create a Resource Group 
az group create --name $groupname --location $location

# Create a Storage Account
az storage account create --name $storagename --resource-group $groupname --location $location \
--sku Standard_LRS

# Create a storage container
az storage container create --account-name $storagename --name $container

# Generates an SAS token for the storage container, valid for one month.
# NOTE: You can use the same SAS token to make backups in App Service until --expiry
sastoken=$(az storage container generate-sas --account-name $storagename --name $container \
--expiry $expirydate --permissions rwdl --output tsv)

# Construct the SAS URL for the container
sasurl=https://$storagename.blob.core.windows.net/$container?$sastoken

# Create an App Service plan in Standard tier. Standard tier allows one backup per day.
az appservice plan create --name $planname --resource-group $groupname --location $location \
--sku S1

# Create a web app
az webapp create --name $webappname --plan $planname --resource-group $groupname

# Create a one-time backup
az webapp config backup create --resource-group $groupname --webapp-name $webappname \
--backup-name $backupname --container-url $sasurl

# List statuses of all backups that are complete or currently executing.
az webapp config backup list --resource-group $groupname --webapp-name $webappname

Output would be similar to: Output 类似于: 输出

References:参考:

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

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