Total Page Preview:   000000002633

How to Create firewall for Azure SQL Server using Powershell

In this article I am going to explain how to create  firewall for Azure SQL Server using powershell

Create firewall for Azure SQL Server using powershell command with ARM Scripts:

#-------- TenantId -------------#

Get TenantId from the Azure Portal: 
Get TenantId In Azure
$tenantid = 'd29b7a9b-6edb-4720-99a8-3c5c6c3eeeb0'
#----------Your UserId and Password--------------------#
$username =  ''
$password = 'xxxxxxxxxxx' | ConvertTo-SecureString -asPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential($username, $password)
Login-AzureRmAccount -TenantId $tenantid -Credential $cred
#------------------------If you have multiple subscriptionId in single account-----------#
$subscriptionId = (Get-AzureRmSubscription | Out-GridView -Title "Select an Azure Subscription …" -PassThru).SubscriptionId
#------------------------for single subscriptionId -----------#
$subscriptionId = (Get-AzureRmSubscription).SubscriptionId
#------------ Please enter already existing Resource group and Azure SQL Server Name -------------#
$rgroup = Read-Host -Prompt 'Enter Resource Group name'
$serverName = Read-Host -Prompt 'Please Enter Azure SQL Server Name' 
Write-Host "Creating Firewall Rule For SQL Server"
$firewallRuleName=  Read-Host  -Prompt 'Enter Rule Name'
$firewallStartIp =  Read-Host  -Prompt 'Enter Start IP'
$firewallEndIp =  Read-Host  -Prompt 'Enter End IP'
#---------------- Firewall rule set for Azure SQL Server -----------------------#
$firewallrule = New-AzureRmSqlServerFirewallRule -ResourceGroupName $rgroup -ServerName` $serverName `
 -FirewallRuleName $firewallRuleName -StartIpAddress $firewallStartIp -EndIpAddress $firewallEndIp
Create firewall for Azure SQL Server using powershell command with ARM:
Create Firewall Rule In Azure SQL Server Using Powershell
By Brijesh Kumar


Thank You

About Author

Brijesh Kumar

Database Developer

I have more then 6 years Experience in Microsoft Technologies - SQL Server Database, ETL Azure Cloud - Azure SQL Database, CosmosDB, Azure Data Factory, PowerBI, Web Job, Azure Function, Azure Storage, Web Apps, Powershall and Database Migration On-Premise to Azure Cloud.
LinkedIn :


I do trust all the ideas you've offered in your post. They are really convincing and will definitely work. Still, the posts are very brief for beginners. May you please prolong them a bit from next time? Thanks for the post.




Facebook User: