New to Azure. I’m attempting to mimic a manual setup through a script run from CloudShell setting up an Azure SQL database. I’ve used this site as a starting point: https://www.sqlshack.com/provisioning-azure-sql-database-using-azure-powershell/
I want to script out:
- A public endpoint as the connectivity method
- Set "Allow Azure services and resources to access this server" to yes
- Set "Add current client IP address" to yes
I’m not familiar with Azure, firewalls so please be gentle.
2
Answers
Read more:
https://www.sharepointdiary.com/2021/07/how-to-connect-to-azure-ad-using-powershell.html#ixzz8D6vt9t6V
https://www.sqlshack.com/provisioning-azure-sql-database-using-azure-powershell/
link to az sql server firewall-rule:
https://learn.microsoft.com/en-us/cli/azure/sql/server/firewall-rule?view=azure-cli-latest
link to Set-AzSqlServer:
https://learn.microsoft.com/en-us/powershell/module/az.sql/set-azsqlserver?view=azps-10.2.0
You can run the PowerShell script below to enable a public IP address in Azure SQL database:
You can see the result as shown below:
And the public network access is enabled as mentioned below:
As per this, if you add a firewall rule with 0.0.0.0 as the start and end IP address to the SQL server, then "Allow Azure services and resources to access this server" is set to yes. Run the script below to set the firewall rule:
You can see the result as mentioned below:
And "Allow Azure services and resources to access this server" is set to yes, as mentioned below:
You can run the script below to add the current IP address to the SQL server. Invoke ‘https://api.ipify.org’ to get the current IP, as mentioned below:
You can see the result as mentioned below:
It will add the current IP address to the firewall rules, as mentioned below: