Azure SQL Server: Get Azure SQL Server Firewall Rules

By Saad Khamis

August 25, 2022

40407 views

Introduction

In this blog I will share one way to get Azure SQL Server firewall rules and the option to save the result in a CSV file. I will also show how to use parameters in PowerShell command.

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. Split-Path Returns the specified part of a path.
  2. Test-Path Determines whether all elements of a path exist.
  3. Get-AzSqlServer Returns information about SQL Database servers.
  4. Get-AzSqlServerFirewallRule Gets firewall rules for a SQL Database server.

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 Azure SQL Server Firewall Rules

The script is easy to follow.

Note the use of parameters in PowerShell command, $SelectProperties. This makes easy to select command output. This is specially useful and helpful when you have complex long scripts.

In conclusion

We explored how to get Azure SQL Server firewall rules. We also used parameters in PowerShell command.

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

List all AWS Certificate Manager certificates

By Saad Khamis 14138 views July 31, 2024

Get all AWS EBS snapshots across all profiles and regions

By Saad Khamis 18496 views June 26, 2024