01 Run sql server show command (Windows/macOS/Linux) using the ID of the primary SQL database server as identifier parameter (see Audit section part II to identify the right resource) to describe the configuration details for the selected SQL server:
az sql server show
--ids "/subscriptions/abcdabcd-1234-abcd-1234-abcdabcdabcd/resourceGroups/cloud-shell-storage-westeurope/providers/Microsoft.Sql/servers/cc-ms-production-server"
02 The command output should return the configuration metadata for the selected server:
{
"fullyQualifiedDomainName": "cc-ms-production-server.database.windows.net",
"id": "/subscriptions/abcdabcd-1234-abcd-1234-abcdabcdabcd/resourceGroups/cloud-shell-storage-westeurope/providers/Microsoft.Sql/servers/cc-ms-production-server",
"administratorLogin": "ccadminusername",
"administratorLoginPassword": null,
"identity": null,
"kind": "v12.0",
"location": "westeurope",
"name": "cc-ms-production-server",
"resourceGroup": "cloud-shell-storage-westeurope",
"state": "Ready",
"tags": {},
"type": "Microsoft.Sql/servers",
"version": "12.0"
}
03 Run sql server create command (Windows/macOS/Linux) using configuration information returned at the previous step, to create a secondary SQL database server in the failover region, in this case, the North Europe region (the command does not produce an output):
az sql server create
--name cc-ms-secondary-server
--resource-group cloud-shell-storage-westeurope
--location northeurope
--admin-user ccadminusername
--admin-password ccadminpassword
--no-wait
04 Run sql failover-group create command (Windows/macOS/Linux) to create an auto-failover group between the primary SQL server and secondary server (i.e. partner server) created at the previous step:
az sql failover-group create
--name cc-auto-failover-group
--server cc-ms-production-server
--partner-server cc-ms-secondary-server
--resource-group cloud-shell-storage-westeurope
--add-db cc-ms-production-database
--failover-policy Automatic
--grace-period 1
05 The command output should return the metadata for the newly created auto-failover group:
{
"databases": [
"/subscriptions/abcdabcd-1234-abcd-1234-abcdabcdabcd/resourceGroups/cloud-shell-storage-westeurope/providers/Microsoft.Sql/servers/cc-ms-production-server/databases/cc-ms-production-database"
],
"id": "/subscriptions/abcdabcd-1234-abcd-1234-abcdabcdabcd/resourceGroups/cloud-shell-storage-westeurope/providers/Microsoft.Sql/servers/cc-ms-production-server/failoverGroups/cc-auto-failover-group",
"location": "West Europe",
"name": "cc-auto-failover-group",
"partnerServers": [
{
"id": "/subscriptions/abcdabcd-1234-abcd-1234-abcdabcdabcd/resourceGroups/cloud-shell-storage-westeurope/providers/Microsoft.Sql/servers/cc-ms-secondary-server",
"location": "North Europe",
"replicationRole": "Secondary",
"resourceGroup": "cloud-shell-storage-westeurope"
}
],
"readOnlyEndpoint": {
"failoverPolicy": "Disabled"
},
"readWriteEndpoint": {
"failoverPolicy": "Automatic",
"failoverWithDataLossGracePeriodMinutes": 60
},
"replicationRole": "Primary",
"replicationState": "CATCH_UP",
"resourceGroup": "cloud-shell-storage-westeurope",
"tags": null,
"type": "Microsoft.Sql/servers/failoverGroups"
}
06 Repeat steps no. 1 – 5 for each SQL server that you want to enable database replication and automatic failover, available in the selected subscription.
07 Repeat steps no. 1 – 6 for each subscription created in your Microsoft Azure cloud account.