Ask Learn
Preview
Ask Learn is an AI assistant that can answer questions, clarify concepts, and define terms using trusted Microsoft documentation.
Please sign in to use Ask Learn.
Sign inThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
In this tutorial, we install a SQL, IIS, .NET stack using Azure PowerShell. This stack consists of two VMs running Windows Server 2016, one with IIS and .NET and the other with SQL Server.
The Azure Cloud Shell is a free interactive shell that you can use to run the steps in this article. It has common Azure tools preinstalled and configured to use with your account.
To open the Cloud Shell, just select Try it from the upper right corner of a code block. You can also launch Cloud Shell in a separate browser tab by going to https://shell.azure.com/powershell. Select Copy to copy the blocks of code, paste it into the Cloud Shell, and press enter to run it.
In this example, we use New-AzVM cmdlet in the PowerShell Cloud Shell to quickly create a Windows Server 2016 VM and then install IIS and the .NET Framework. The IIS and SQL VMs share a resource group and virtual network, so we create variables for those names.
$vmName = "IISVM"
$vNetName = "myIISSQLvNet"
$resourceGroup = "myIISSQLGroup"
New-AzVm `
-ResourceGroupName $resourceGroup `
-Name $vmName `
-Location "East US" `
-VirtualNetworkName $vNetName `
-SubnetName "myIISSubnet" `
-SecurityGroupName "myNetworkSecurityGroup" `
-AddressPrefix 192.168.0.0/16 `
-PublicIpAddressName "myIISPublicIpAddress" `
-OpenPorts 80,3389
Install IIS and the .NET framework using the custom script extension with the Set-AzVMExtension cmdlet.
Set-AzVMExtension `
-ResourceGroupName $resourceGroup `
-ExtensionName IIS `
-VMName $vmName `
-Publisher Microsoft.Compute `
-ExtensionType CustomScriptExtension `
-TypeHandlerVersion 1.4 `
-SettingString '{"commandToExecute":"powershell Add-WindowsFeature Web-Server,Web-Asp-Net45,NET-Framework-Features"}' `
-Location EastUS
Create a second subnet for the SQL VM. Get the vNet using [Get-AzVirtualNetwork]{/powershell/module/az.network/get-azvirtualnetwork}.
$vNet = Get-AzVirtualNetwork `
-Name $vNetName `
-ResourceGroupName $resourceGroup
Create a configuration for the subnet using Add-AzVirtualNetworkSubnetConfig.
Add-AzVirtualNetworkSubnetConfig `
-AddressPrefix 192.168.0.0/24 `
-Name mySQLSubnet `
-VirtualNetwork $vNet `
-ServiceEndpoint Microsoft.Sql
Update the vNet with the new subnet information using Set-AzVirtualNetwork
$vNet | Set-AzVirtualNetwork
Use a pre-configured Azure marketplace image of a SQL server to create the SQL VM. We first create the VM, then we install the SQL Server Extension on the VM.
New-AzVm `
-ResourceGroupName $resourceGroup `
-Name "mySQLVM" `
-ImageName "MicrosoftSQLServer:SQL2016SP1-WS2016:Enterprise:latest" `
-Location eastus `
-VirtualNetworkName $vNetName `
-SubnetName "mySQLSubnet" `
-SecurityGroupName "myNetworkSecurityGroup" `
-PublicIpAddressName "mySQLPublicIpAddress" `
-OpenPorts 3389,1401
Use Set-AzVMSqlServerExtension to add the SQL Server extension to the SQL VM.
Set-AzVMSqlServerExtension `
-ResourceGroupName $resourceGroup `
-VMName mySQLVM `
-Name "SQLExtension" `
-Location "EastUS"
In this tutorial, you installed a SQL\IIS\.NET stack using Azure PowerShell. You learned how to:
Advance to the next tutorial to learn how to secure IIS web server with TLS/SSL certificates.
Ask Learn is an AI assistant that can answer questions, clarify concepts, and define terms using trusted Microsoft documentation.
Please sign in to use Ask Learn.
Sign in