Azure App Services: Get App Services Role Assignments, including slots

By Saad Khamis

August 25, 2022

27638 views

Introduction

In this blog I will share one way to get an Azure App Service (WebApp), and associated slots, role assignments.

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

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, solution or process to accomplish a task.

Prerequisites

  1. First thing to remember is to install Azure PowerShell. Otherwise, you can use Cloud Shell if you prefer to stay within Azure Portal.

PowerShell Cmdlets

  1. Get-AzWebApp Gets Azure Web Apps in the specified resource group.
  2. Get-AzRoleAssignment Lists Azure RBAC role assignments at the specified scope. By default it lists all role assignments in the selected Azure subscription. Use respective parameters to list assignments to a specific user, or to list assignments on a specific resource group or resource.
  3. 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 Role Assignments

The script is easy to follow.

Calculated fields

I used calculated fields to display WebApp name and Slot name.

ValueExpressionResult
WebApp1@{Name=”App”;Expression={$WebApp.Name}}WebApp1
WebApp1/Stage@{N=”Slot”;E={$AppSlot.Name.Split(‘/’)[1]}}Stage

In conclusion

In summary, we explored how to get role assignments for all exiting App Services (WebApp).

Did you find this blog easy to follow and helpful to you? I certainly would love to hear your feedback and suggestions. So, let me know in the comments below. Happy PowerShelling.

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 17348 views November 27, 2023

Windows – Get all installed patches, updates and hotfixes

By Saad Khamis 22063 views October 25, 2023

Azure – Get Storage Account Lifecycle Management Policy Rules

By Saad Khamis 35641 views October 12, 2023