Azure App Services: Get Scheduled Backup Configuration for a Single App Service and Associated Slots using PowerShell

By Saad Khamis

October 16, 2021

10145 views

In this blog I will share one way to get Azure App Services scheduled backup configuration for a single App Service and its 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 all App Services and their slots, review Azure App Services: Get Scheduled Backup Configuration for All App Services 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. A single App Service.
  2. A single App Service and its 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-AzWebAppBackupConfiguration Gets the backup configuration of an Azure Web App.
  4. 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 a single App Service

  1. Use Get-AzWebAppBackupConfiguration to get App Service scheduled backup configuration.

Get scheduled backup configuration for a single App Service and its slots

  1. Initialize an array variable, $OutTable, to save output.
  2. Get App Service scheduled backup configuration.
  3. Add App Service scheduled backup configuration to $OutTable.
  4. Use Get-AzWebAppSlot to get App Service slots.
  5. If the App Service has slots, get slot scheduled backup configuration.
  6. (a) For each slot, (b) get slot scheduled backup configuration.
  7. If the web App does not have a backup schedule, add “No backup scheduled” to $OutTable otherwise add slot scheduled backup configuration to $OutTable.
  8. 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

AWS EC2 – Get all EC2 instances in all profiles and all regions

By Saad Khamis 17347 views November 27, 2023

Windows – Get all installed patches, updates and hotfixes

By Saad Khamis 22062 views October 25, 2023

Azure – Get Storage Account Lifecycle Management Policy Rules

By Saad Khamis 35640 views October 12, 2023