Azure App Services: Get Scheduled Backup Configuration for All App Services and Associated Slots using PowerShell

By Saad Khamis

October 17, 2021

15646 views

In this blog I will share one way to get Azure App Services scheduled backup configuration for a all App Services and all App Services and each App Service Slots using PowerShell.

My blogs have relatively simple, and sometimes complex, examples and I’m hoping that you will be able to tailor them to your need or use them in your own scripts.

To get scheduled backup configuration for a single App Service and its slots, Azure App Services: Get Scheduled Backup Configuration for a Single App Service and Associated Slots using PowerShell.

To get App Services deployment slots, review Azure App Services: Get Deployment Slots using PowerShell.

Prerequisites

  1. Install Azure PowerShell if you haven’t already. You can use Cloud Shell if you prefer to stay within Azure Portal.
  2. Install Azure Active Directory PowerShell module if you haven’t already. You can use Cloud Shell if you prefer to stay within Azure Portal.

Introduction

The goal of this blog is to show one way to accomplish a task. It is not to show how to write a perfect script, the perfect solution to a challenge or the perfect process to accomplish a task.

Using PowerShell, I will show you how to get scheduled backup configuration for:

  1. All App Services.
  2. All App Services and each App Service Slots.

I will also show, for demonstration, how to display PowerShell cmdlet output in a table format.

PowerShell Cmdlets

  1. Connect-AzAccount Connect to Azure with an authenticated account for use with cmdlets from the Az PowerShell modules.
  2. Set-AzContext Sets the tenant, subscription, and environment for cmdlets to use in the current session.
  3. Get-AzWebApp Gets Azure Web Apps in the specified resource group.
  4. Get-AzWebAppBackupConfiguration Gets the backup configuration of an Azure Web App.
  5. Get-AzWebAppSlot Gets an Azure Web App slot.

Sign in to Azure

  1. Sign in to Azure. If you have multiple subscriptions or tenants, make sure to sign in to the correct subscription.
  2. You can use Set-AzContext to set the tenant, subscription, and environment for cmdlets to use in the current session.

Get scheduled backup configuration for all App Services

  1. Use Get-AzWebApp to get a list of all App Services in the subscription.
  2. Initialize a variable, $OutTable, to save output.
  3. (a) For each Web App, (b) use Get-AzWebAppBackupConfiguration to get the App Service scheduled backup configuration.
  4. If the App Service does not have a scheduled backup configuration, add “No backup scheduled” to $OutTable.
  5. If the App Service has a scheduled backup configuration, add it to $OutTable.
  6. Display $OutTable.

Get scheduled backup configuration for all App Services and each App Service Slots

  1. Use Get-AzWebApp to get a list of all App Services in the subscription.
  2. Initialize a variable, $OutTable, to save output.
  3. (a) For each Web App, (b) get the App Service scheduled backup configuration using Get-AzWebAppBackupConfiguration.
  4. If the App Service does not have a scheduled backup configuration, add “No backup scheduled” to $OutTable otherwise add scheduled backup configuration to $OutTable.
  5. Use Get-AzWebAppSlot to get App Service slots
  6. If the App Service has slots, get scheduled backup configuration for each slot. Otherwise, go to the next App Service.
  7. (a) For each slot, (b) get slot scheduled backup configuration.
  8. If the App Service slot does not have a scheduled backup configuration, add “No backup scheduled” to $OutTable otherwise add scheduled backup configuration to $OutTable.
  9. Display $OutTable.

Conclusion

In this blog we explored how to get Azure App Services scheduled backup configuration using PowerShell. We also explored how to output PowerShell cmdlet result as a table.

Did you find this blog easy to follow and helpful to you? Let me know in the comments below.

Disclaimer

Purpose of the code contained in blog is solely for learning and demo purposes. Author will not be held responsible for any failure or damages caused due to any other usage.

Comments

There's no comments

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Posts

List all AWS Certificate Manager certificates

By Saad Khamis 14092 views July 31, 2024

Get all AWS EBS snapshots across all profiles and regions

By Saad Khamis 18450 views June 26, 2024