Azure PowerShell を使用して Web のバックアップを削除する

このサンプル スクリプトでは、App Service で Web アプリを関連リソースと合わせて作成し、これに対する 1 回限りのバックアップを作成します。

このスクリプトを実行するには、Web アプリの既存のバックアップが必要です。 これを作成するには、「Backup up a web app」 (Web アプリのバックアップ) または「Create a scheduled backup for a web app」 (Web アプリのスケジュールされたバックアップの作成) をご覧ください。

サンプル スクリプト

注意

Azure を操作するには、Azure Az PowerShell モジュールを使用することをお勧めします。 作業を開始するには、「Azure PowerShell のインストール」を参照してください。 Az PowerShell モジュールに移行する方法については、「AzureRM から Az への Azure PowerShell の移行」を参照してください。

# 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

スクリプトの説明

このスクリプトでは、次のコマンドを使用します。 表内の各コマンドは、それぞれのドキュメントにリンクされています。

コマンド Notes
Get-AzWebAppBackupList Web アプリのバックアップの一覧を取得します。
Remove-AzWebAppBackup Web アプリの指定したバックアップを削除します。

次のステップ

Azure PowerShell モジュールの詳細については、Azure PowerShell のドキュメントを参照してください。

その他の Azure App Service Web Apps 用 Azure PowerShell サンプルは、Azure PowerShell サンプルのページにあります。