loading...
Cover image for My first Powershell Azure Function

My first Powershell Azure Function

antoinega profile image Antoine ・1 min read

Photo by Tim Mossholder on Unsplash

I'm mostly a C# developer. Lastly, i had to programmatically modify an Azure Web application to add or remove firewall rules in a Web application and a SQL one.
To me, it was obvious to use:

It was easy for the SQL part.
but i was stuck for the Web application part, as the firewall rules was part of the inner configuration of the web application.

It was a surprise to me as the Powershell Core command was pretty simple to use.
So i was gladly surprised to see powershell function available, and the experience is simple.

Modules

I just need Az modules to complete my task. In order to check which modules are available, i just have to insert those lines in the function:

Get-Module -ListAvailable | Select-Object Name, Version | Sort-Object -Property Name

Az modules are here, so nothing to install.

Identity

For the authentication / authorization part, i rely on a Managed Service Identity, and on role based authorization control (RBAC) on the Web application.

In order to connect and i have the right identity i just have to:

Connect-AzAccount -Identity
$az = Get-AzContext
write-host $az

Command to execute

I just have to execute the command to add the access :

Add-AzWebAppAccessRestrictionRule

Hope this helps !

Posted on by:

antoinega profile

Antoine

@antoinega

mainly .Net but looking for great stuff about anything

Discussion

pic
Editor guide