使用 Azure PowerShell 來刪除 Web 備份

此範例指令碼會在 App Service 中建立 Web 應用程式及其相關資源,然後為其建立一次性的備份。

若要執行此指令碼,您需要 Web 應用程式的現有備份。 若要建立一個,請參閱 Web 應用程式建立 Web 應用程式的排程備份

範例指令碼

注意

建議您使用 Azure Az PowerShell 模組來與 Azure 互動。 請參閱安裝 Azure PowerShell 以開始使用。 若要了解如何移轉至 Az PowerShell 模組,請參閱將 Azure PowerShell 從 AzureRM 移轉至 Az

# This sample script creates a web app in App Service with its related resources, and then creates a one-time backup for it.
# To run this script, you need an existing backup for a web app. To create one, see Backup up a web app or Create a scheduled backup for a web app.

$resourceGroupName = "myResourceGroup"
$webappname = "<replace-with-your-app-name>"

# List statuses of all backups that are complete or currently executing.
Get-AzWebAppBackupList -ResourceGroupName $resourceGroupName -Name $webappname

# Note the BackupID property of the backup you want to delete

# Delete the backup by specifying the BackupID
Remove-AzWebAppBackup -ResourceGroupName $resourceGroupName -Name $webappname `
-BackupId '<replace-with-BackupID>'

清除部署

在執行過指令碼範例之後,您可以使用下列命令來移除資源群組、Web 應用程式和所有相關資源。

Remove-AzResourceGroup -Name myResourceGroup -Force

指令碼說明

此指令碼會使用下列命令。 下表中的每個命令都會連結至命令特定的文件。

Command 注意
Get-AzWebAppBackupList 取得 Web 應用程式的備份清單。
Remove-AzWebAppBackup 移除指定的 Web 應用程式備份。

下一步

如需有關 Azure PowerShell 模組的詳細資訊,請參閱 Azure PowerShell 文件

您可以在 Azure PowerShell 範例中找到適用於 App Service Web Apps 的其他 Azure PowerShell 範例。