Created
July 19, 2016 05:31
-
-
Save sarangbk/19abf407f33803521bd223f5f6ef287e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add-AzureRmAccount | |
Set-AzureRmContext -SubscriptionId '<Enter SubscriptionId here only if you have more than one subscriptions for the same email address/identity>' | |
$firewallRuleName = '<firewalll rule to remove/update if it already exists>' | |
$serverName = '<Database Server name for which rule is to be added>' | |
$resourceGroupName = '<Resource group of database server>' | |
$myIp = (Invoke-WebRequest ifconfig.me/ip).Content.Trim() | |
Write-Host 'Creating firewalll rule for ip',$myIp | |
Remove-AzureRmSqlServerFirewallRule -FirewallRuleName $firewallRuleName -ResourceGroupName $resourceGroupName -ServerName $serverName -WarningAction Continue -Force -ErrorAction Continue | |
New-AzureRmSqlServerFirewallRule -ResourceGroupName $resourceGroupName -ServerName $serverName -FirewallRuleName $firewallRuleName -StartIpAddress $myIp -EndIpAddress $myIp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment