Deploys SQL Server 2014 AG on existing VNET & AD

Azure Public Test Date Azure Public Test Result

Azure US Gov Last Test Date Azure US Gov Last Test Result

Best Practice Check Cred Scan Check

Bicep Version

This template will create a SQL Server 2014 availability group using the PowerShell DSC Extension in an existing Azure Virtual Network and Active Directory environment.

This template creates the following resources:

  • Three Storage Accounts
  • One internal load balancer
  • Three VMs in a Windows Server Cluster, two VMs run SQL Server 2014 with an availability group and the third is a File Share Witness for the Cluster
  • One Availability Set for the SQL and Witness VMs

A SQL Server always on listener is created using the internal load balancer.

To deploy the required Azure VNET and Active Directory infrastructure, if not already in place, you may use this template to deploy the prerequisite infrastructure.


  • This template is designed for lab or testing use only

  • This template requires domain administrator privileges

  • The default settings for storage are to deploy using premium storage. The SQL VMs use two P30 disks each (for data and log). These sizes can be changed by changing the relevant variables. In addition there is a P10 Disk used for each VM OS Disk.

  • The default settings for compute require that you have at least 9 cores of free quota to deploy.

  • The images used to create this deployment are

    • SQL Server - Latest SQL Server 2014 on Windows Server 2012 R2 Image
    • Witness - Latest Windows Server 2012 R2 Image
  • The image configuration is defined in variables, but the scripts that configure this deployment have only been tested with these versions and may not work on other images.

  • To successfully deploy this template, be sure that the subnet to which the SQL VMs are being deployed already exists on the specified Azure virtual network, AND this subnet should be defined in Active Directory Sites and Services for the appropriate AD site in which the closest domain controllers are configured.

Click the button below to deploy from the portal

Deploy To Azure Deploy To Azure US Gov Visualize

Deploying Sample Templates

You can deploy these samples directly through the Azure Portal or by using the scripts supplied in the root of the repo.

To deploy a sammple using the Azure Portal, click the Deploy to Azure button found in the of each sample.

To deploy the sample via the command line (using Azure PowerShell or the Azure CLI) you can use the scripts.

Simple execute the script and pass in the folder name of the sample you want to deploy. For example:

.\Deploy-AzureResourceGroup.ps1 -ResourceGroupLocation 'eastus' -ArtifactsStagingDirectory '[foldername]' -a [foldername] -l eastus -u

If the sample has artifacts that need to be "staged" for deployment (Configuration Scripts, Nested Templates, DSC Packages) then set the upload switch on the command. You can optionally specify a storage account to use, if so the storage account must already exist within the subscription. If you don't want to specify a storage account one will be created by the script or reused if it already exists (think of this as "temp" storage for AzureRM).

.\Deploy-AzureResourceGroup.ps1 -ResourceGroupLocation 'eastus' -ArtifactsStagingDirectory '201-vm-custom-script-windows' -UploadArtifacts -a '201-vm-custom-script-windows' -l eastus -u

Tags: cluster, ha, sql, alwayson

Tags: Microsoft.Resources/deployments, Microsoft.Compute/virtualMachines/extensions, DSC, Microsoft.Compute/availabilitySets, Microsoft.Network/loadBalancers, Microsoft.Network/networkInterfaces, Microsoft.Compute/virtualMachines