Skip to content

Latest commit

 

History

History
123 lines (80 loc) · 4.81 KB

File metadata and controls

123 lines (80 loc) · 4.81 KB
title Create SQL Server VM using Bicep
description Learn how to create a SQL Server on Azure Virtual Machine (VM) using Bicep.
author adbadram
ms.author adbadram
ms.date 06/17/2022
ms.service virtual-machines-sql
ms.subservice deployment
ms.topic quickstart
ms.custom
subject-armqs
devx-track-azurepowershell
mode-arm

Quickstart: Create SQL Server VM using Bicep

This quickstart shows you how to use Bicep to create an SQL Server on Azure Virtual Machine (VM).

Bicep is a domain-specific language (DSL) that uses declarative syntax to deploy Azure resources. It provides concise syntax, reliable type safety, and support for code reuse. Bicep offers the best authoring experience for your infrastructure-as-code solutions in Azure.

Prerequisites

The SQL Server VM Bicep file requires the following:

Review the Bicep file

The Bicep file used in this quickstart is from Azure Quickstart Templates.

:::code language="bicep" source="~/../quickstart-templates/quickstarts/microsoft.sqlvirtualmachine/sql-vm-new-storage/main.bicep":::

Five Azure resources are defined in the Bicep file:

Deploy the Bicep file

  1. Save the Bicep file as main.bicep to your local computer.

  2. Deploy the Bicep file using either Azure CLI or Azure PowerShell.

    az deployment group create --resource-group exampleRG --template-file main.bicep --parameters existingSubnetName=<subnet-name> adminUsername=<admin-user> adminPassword=<admin-pass>
    
    New-AzResourceGroupDeployment -ResourceGroupName exampleRG -TemplateFile ./main.bicep -administratorLogin "<admin-login>" -adminUsername "<admin-user>" -adminPassword "<admin-pass>"
    

Make sure to replace the resource group name, exampleRG, with the name of your pre-configured resource group.

You're required to enter the following parameters:

  • existingSubnetName: Replace <subnet-name> with the name of the subnet.
  • adminUsername: Replace <admin-user> with the admin username of the VM.

You'll also be prompted to enter adminPassword.

Note

When the deployment finishes, you should see a message indicating the deployment succeeded.

Review deployed resources

Use the Azure portal, Azure CLI, or Azure PowerShell to list the deployed resources in the resource group.

az resource list --resource-group exampleRG
Get-AzResource -ResourceGroupName exampleRG

Clean up resources

When no longer needed, use the Azure portal, Azure CLI, or Azure PowerShell to delete the resource group and its resources.

az group delete --name exampleRG
Remove-AzResourceGroup -Name exampleRG

Next steps

For a step-by-step tutorial that guides you through the process of creating a Bicep file with Visual Studio Code, see:

[!div class="nextstepaction"] Quickstart: Create Bicep files with Visual Studio Code

For other ways to deploy a SQL Server VM, see:

To learn more, see an overview of SQL Server on Azure VMs.