Azure / PowerShell / Deploy Azure SQL database DR environment (PaaS) using PowerShell

Script Download:

The script with usage example is available for download from


Use PowerShell to create cloud DR environment using Azure SQL Databases (PaaS) and send Email Report with the connection string details



Use PowerShell to deploy cloud service with Azure SQL Database (PaaS) with good resilience to outages (GEO Replications, Failover Groups)


  • Connect to Azure Account,
  • Use existing or create new Resource Group,
  • Create primary Azure Logical SQL Server,
  • Set an admin login and password for your server,
  • Set Firewall Settings (IP address range),
  • Create Azure SQL Database,
  • Create a new login for the Azure SQL Server,
  • Create a new DB user for the created login,
  • Create failover Azure Logical SQL Server, including admin login, password and firewall rules (Optional),
  • Create Failover Group Name (Optional),
  • Add Database to the existing Failover Group (Optional),
  • Create a new login for the Failover Azure SQL Server with matching SID (Optional),
  • Send Email notification with connection string parameters.


Script usage example:


You can repeat the script multiple times. If the resource you are creating already exist script will just skip that part with a message. 


You should use read/write listener endpoint within the connection string.


Similar Posts:

Leave a Reply

Your email address will not be published. Required fields are marked *