updates to variables and subscription (#13695)

* updates to variablesand subscription

previous notebook was not taking Subscription into account. Here, I'm setting to use the az context explicitly with the $Subscription variable

* Converted appendix to nb, wording

* remove whitespace, add clarity
This commit is contained in:
Christopher C
2021-01-25 17:31:32 -08:00
committed by GitHub
parent 42a8680738
commit 728aeded01
4 changed files with 154 additions and 123 deletions

View File

@@ -78,4 +78,4 @@
- title: Glossary - title: Glossary
url: /glossary url: /glossary
- title: Appendices - title: Appendices
url: /appendices url: /Appendices

View File

@@ -0,0 +1,104 @@
{
"metadata": {
"kernelspec": {
"name": "powershell",
"display_name": "PowerShell",
"language": "powershell"
},
"language_info": {
"name": "powershell",
"codemirror_mode": "shell",
"mimetype": "text/x-sh",
"file_extension": ".ps1"
}
},
"nbformat_minor": 2,
"nbformat": 4,
"cells": [
{
"cell_type": "markdown",
"source": [
"# Appendices"
],
"metadata": {
"azdata_cell_guid": "7894d5e9-9d20-462a-942d-5819c9eef811"
}
},
{
"cell_type": "markdown",
"source": [
"## Appendix: Locations\r\n",
"See the <a href=\"https://azure.microsoft.com/en-us/global-infrastructure/locations/\">Azure locations</a> page for a complete list of Azure regions along with their general physical location. The following is a list of common North American location settings for this guide:\r\n",
"\r\n",
"### Regions\r\n",
"| Setting | Location\r\n",
"| ------------ | ---------\r\n",
"| Central US | Iowa\r\n",
"| East US | Virginia\r\n",
"| East US 2 | Virginia\r\n",
"| North Central US | Illinois\r\n",
"| South Central US | Texas\r\n",
"| West US 2 | Washington\r\n",
"| West Central US | Wyoming\r\n",
"| West US | California\r\n",
"| Canada Central | Toronto\r\n",
"| Canada East | Quebec City\r\n",
"| Brazil South | Sao Paulo\r\n",
"| Mexico Central | Queretaro"
],
"metadata": {
"azdata_cell_guid": "31b9ebca-6102-438b-8a1c-d14c2598abc5"
}
},
{
"cell_type": "markdown",
"source": [
"## Appendix: Storage SKUs\r\n",
"Use these as values for provisioning storage skus. \r\n",
"\r\n",
"Data for table taken from <a href=\"https://docs.microsoft.com/en-us/rest/api/storagerp/srp_sku_types\">SKU Types</a> page but is subject to change. Not all skus are listed here. SKU type names are case-sensitive.\r\n",
"\r\n",
"| Name | Description |\r\n",
"| -----| ----------- |\r\n",
"| Standard_LRS | standard locally redundant storage |\r\n",
"| Standard_GRS | standard geo-replicated storage |\r\n",
"| Standard_RAGRS | standard read-access geo replicated storage |\r\n",
"| Standard_ZRS | standard zone redundant storage |\r\n",
"| Premium_LRS | Premium - provisioned IO locally redundant |\r\n",
"| Premium_ZRS | Premium - provisioned IO locally redundant |\r\n",
""
],
"metadata": {
"azdata_cell_guid": "a5272577-2f81-4cea-8dc2-8aaa7bbb6603"
}
},
{
"cell_type": "markdown",
"source": [
"## Appendix: Azure SQL VM Offers\n",
"\n",
"Run the following command using PowerShell to get updated list of offers for Microsoft SQL Server in a location. These settings can be used for the OfferName associated with this migration. \n",
"\n",
"Note that the SQL Version is first then appended with an operating system version. E.g.: \"WS2019\" means Windows Server 2019. Along with various versions of Windows Servers, there are also enterprise Linux versions such as RedHat Enterprise, Suse Enterprise, and Ubuntu. Some versions are BYOL (Bring Your Own License) aka [Hybrid Benefit](https://azure.microsoft.com/en-us/pricing/hybrid-benefit/)."
],
"metadata": {
"azdata_cell_guid": "3a67fc67-c1d3-4dcc-b2a0-5f893d175000"
}
},
{
"cell_type": "code",
"source": [
"$Location = \"\" # Name of location to discover offering \r\n",
"$PublisherName = \"\" # Name of Publisher, Default would be 'MicrosoftSQLServer'\r\n",
"\r\n",
"Connect-AzAccount # Opens a dialog in another window\r\n",
"Get-AzVMImageOffer -Location $Location -Publisher $PublisherName | Select Offer"
],
"metadata": {
"azdata_cell_guid": "7eb125fd-dce9-4421-89c8-8c4830e3bfe7"
},
"outputs": [],
"execution_count": null
}
]
}

View File

@@ -1,35 +0,0 @@
# Appendices
[Home](readme.md)
## Appendix: Locations
See the <a href="https://azure.microsoft.com/en-us/global-infrastructure/locations/">Azure locations</a> page for a complete list of Azure regions along with their general physical location. The following is a list of common North American location settings for this guide:
### Regions
| Setting | Location |
| ------------ | --------- |
| Central US | Iowa |
| East US | Virginia |
| East US 2 | Virginia |
| North Central US | Illinois |
| South Central US | Texas |
| West US 2 | Washington |
| West Central US | Wyoming |
| West US | California |
| Canada Central | Toronto |
| Canada East | Quebec City |
| Brazil South | Sao Paulo |
| Mexico Central | Queretaro |
## Appendix: Storage SKUs
Use these as values for provisioning storage skus.
Data for table taken from <a href="https://docs.microsoft.com/en-us/rest/api/storagerp/srp_sku_types">SKU Types</a> page but is subject to change. Not all skus are listed here. SKU type names are case-sensitive.
| Name | Description |
| -----| ----------- |
| Standard_LRS | standard locally redundant storage |
| Standard_GRS | standard geo-replicated storage |
| Standard_RAGRS | standard read-access geo replicated storage |
| Standard_ZRS | standard zone redundant storage |
| Premium_LRS | Premium - provisioned IO locally redundant |
| Premium_ZRS | Premium - provisioned IO locally redundant |

View File

@@ -2,7 +2,8 @@
"metadata": { "metadata": {
"kernelspec": { "kernelspec": {
"name": "powershell", "name": "powershell",
"display_name": "PowerShell" "display_name": "PowerShell",
"language": "powershell"
}, },
"language_info": { "language_info": {
"name": "powershell", "name": "powershell",
@@ -17,21 +18,21 @@
{ {
"cell_type": "markdown", "cell_type": "markdown",
"source": [ "source": [
"Create Azure SQL Virtual Machine\n", "# Create Azure SQL Virtual Machine\n",
"============================================\n",
"\n", "\n",
"Description\n", "## Description\n",
"-----------\n",
"For more information about other Azure PowerShell options for creating SQL VMs, see the <a href=\"https://docs.microsoft.com/en-us/azure/virtual-machines/windows/sql/virtual-machines-windows-ps-sql-create\">Provisioning guide for SQL Server VMs with Azure PowerShell</a>. See also <a href=\"https://docs.microsoft.com/en-us/azure/virtual-machines/windows/sql/quickstart-sql-vm-create-powershell\">Quickstart guide</a> to creating a SQL Server VM with Azure PowerShell.\n",
"\n", "\n",
"For more information about other Azure PowerShell options for creating SQL VMs, see the [Provisioning guide for SQL Server VMs with Azure PowerShell](https://docs.microsoft.com/en-us/azure/virtual-machines/windows/sql/virtual-machines-windows-ps-sql-create). See also [Quickstart guide](https://docs.microsoft.com/en-us/azure/virtual-machines/windows/sql/quickstart-sql-vm-create-powershell) to creating a SQL Server VM with Azure PowerShell.\n",
"\n", "\n",
"Steps of this procedure include:\n", "Steps of this procedure include:\n",
"1. Connect to Azure subscription\n", "\n",
"1. Provision resource group for SQL VM migration\n", "1. Define notebook variables\n",
"2. Create a storage account\n", "2. Connect to Azure subscription\n",
"3. Configure Network Settings\n", "3. Provision resource group for SQL VM migration\n",
"3. Provision SQL VM\n", "4. Create a storage account\n",
"4. Configure SQL VM IaaS agent" "5. Configure Network Settings\n",
"6. Provision SQL VM\n",
"7. Configure SQL VM IaaS agent"
], ],
"metadata": { "metadata": {
"azdata_cell_guid": "e479b550-d6bd-49c5-965a-34a7d1d16412" "azdata_cell_guid": "e479b550-d6bd-49c5-965a-34a7d1d16412"
@@ -40,7 +41,7 @@
{ {
"cell_type": "markdown", "cell_type": "markdown",
"source": [ "source": [
"#### <b> *Enter all the values in quotes *</b>" "## Define Notebook Variables"
], ],
"metadata": { "metadata": {
"azdata_cell_guid": "37db2e50-dcde-4dd5-820c-7dc11212f1eb" "azdata_cell_guid": "37db2e50-dcde-4dd5-820c-7dc11212f1eb"
@@ -50,21 +51,22 @@
"cell_type": "code", "cell_type": "code",
"source": [ "source": [
"# Resource Group \r\n", "# Resource Group \r\n",
"$ResourceGroupName = \"\" # Name of the resource group to create in the current subscription\r\n", "$Subscription = \"\" # Leave blank to open a dialog to get Azure Subscription, or explicitly specify\r\n",
"$Location = \"\" # see Appendix for a list of location settings\r\n", "$ResourceGroup = \"\" # Name of the resource group to create in the current subscription\r\n",
"$Location = \"\" # see Appendix for a list of location settings\r\n",
"\r\n", "\r\n",
"# Compute\r\n", "# Compute\r\n",
"$VMName = \"\" # VM to create\r\n", "$VMName = \"\" # VM to create\r\n",
"$PublisherName = \"\" # Name of Publisher, Default would be 'MicrosoftSQLServer'\r\n", "$PublisherName = \"\" # Name of Publisher, Default would be 'MicrosoftSQLServer'\r\n",
"$Version = \"\" # Version of VM, Default would be 'latest'\r\n", "$Version = \"\" # Version of VM, Default would be 'latest'\r\n",
"\r\n", "\r\n",
"# Storage\r\n", "# Storage\r\n",
"$StorageAccountName = $ResourceGroupName + \"_storage\"\r\n", "$StorageAccountName = $ResourceGroup + \"_storage\"\r\n",
"$StorageSku = \"\" # Choose your storage sku (see appendix)\r\n", "$StorageSKU = \"\" # Choose your storage SKU (see appendix)\r\n",
"$StorageName = \"sqlstorage\" + (Get-Random -Minimum 1 -Maximum 100)\r\n", "$StorageName = \"sqlstorage\" + (Get-Random -Minimum 1 -Maximum 100)\r\n",
"\r\n", "\r\n",
"# VM Password\r\n", "# VM Password\r\n",
"$secureVMPassword = \"\" # Create the password for VM." "$secureVMPassword = \"\" # Create the password for VM."
], ],
"metadata": { "metadata": {
"azdata_cell_guid": "b9aff9cc-a3af-41cb-a2a5-35f36b2bcc55", "azdata_cell_guid": "b9aff9cc-a3af-41cb-a2a5-35f36b2bcc55",
@@ -76,28 +78,9 @@
{ {
"cell_type": "markdown", "cell_type": "markdown",
"source": [ "source": [
"## Connect to Azure Account" "## Get Subscription\n",
], "\n",
"metadata": { "Open a dialog box with a list of subscriptions, if one isn't specified. Selecting one will set that subscription in the Az CLI context for rest of the notebook."
"azdata_cell_guid": "b06fee5e-355d-47fc-8c1f-41294756cc87"
}
},
{
"cell_type": "code",
"source": [
"Connect-AzAccount"
],
"metadata": {
"azdata_cell_guid": "7dbdc638-d6cd-4ebe-9268-3efc18d3c415"
},
"outputs": [],
"execution_count": null
},
{
"cell_type": "markdown",
"source": [
"## Get Subscription\r\n",
"Below command will open a _Dialouge Box_ with list of subscriptions. Selecting one of those will set that subscription for rest of the commands."
], ],
"metadata": { "metadata": {
"azdata_cell_guid": "b58f1048-3e9d-4888-bda0-4d0443a11c97" "azdata_cell_guid": "b58f1048-3e9d-4888-bda0-4d0443a11c97"
@@ -106,8 +89,12 @@
{ {
"cell_type": "code", "cell_type": "code",
"source": [ "source": [
"$subscription = Get-AzSubscription | Out-GridView -PassThru\r\n", "if (!$Subscription)\r\n",
"Set-AzContext -SubscriptionName $subscription" "{\r\n",
" $Subscription = Get-AzSubscription | Out-GridView -PassThru\r\n",
"} \r\n",
"Set-AzContext -SubscriptionName $Subscription\r\n",
"Connect-AzAccount -Subscription $Subscription"
], ],
"metadata": { "metadata": {
"azdata_cell_guid": "0cc44e68-3810-46f4-b29c-e6ad4321e384" "azdata_cell_guid": "0cc44e68-3810-46f4-b29c-e6ad4321e384"
@@ -128,13 +115,13 @@
"cell_type": "code", "cell_type": "code",
"source": [ "source": [
"# Create Azure resource group, if necessary\r\n", "# Create Azure resource group, if necessary\r\n",
"$rg = Get-AzResourceGroup | Where ResourceGroupName -eq $ResourceGroupName\r\n", "$rg = Get-AzResourceGroup | Where ResourceGroupName -eq $ResourceGroup\r\n",
"\r\n", "\r\n",
"if (!$rg)\r\n", "if (!$rg)\r\n",
"{\r\n", "{\r\n",
" # Need to create a new resource group\r\n", " # Need to create a new resource group\r\n",
" Write-Output \"Resource Group $ResourceGroupName does not exist. Creating...\"\r\n", " Write-Output \"Resource Group '$ResourceGroup' does not exist\"\r\n",
" $rg = New-AzResourceGroup -Name $ResourceGroupName -Location $Location\r\n", " $rg = New-AzResourceGroup -Name $ResourceGroup -Location $Location\r\n",
"}" "}"
], ],
"metadata": { "metadata": {
@@ -161,7 +148,7 @@
"if (!$StorageAccount)\r\n", "if (!$StorageAccount)\r\n",
"{\r\n", "{\r\n",
" Write-Output \"Storage Account $StorageName does not exist. Creating...\"\r\n", " Write-Output \"Storage Account $StorageName does not exist. Creating...\"\r\n",
" $StorageAccount = New-AzStorageAccount -ResourceGroupName $ResourceGroupName -Name $StorageName -SkuName $StorageSku -Kind \"Storage\" -Location $Location\r\n", " $StorageAccount = New-AzStorageAccount -ResourceGroupName $ResourceGroup -Name $StorageName -SkuName $StorageSku -Kind \"Storage\" -Location $Location\r\n",
"}" "}"
], ],
"metadata": { "metadata": {
@@ -184,19 +171,19 @@
{ {
"cell_type": "code", "cell_type": "code",
"source": [ "source": [
"$SubnetName = $ResourceGroupName + \"subnet\"\r\n", "$SubnetName = $ResourceGroup + \"subnet\"\r\n",
"$VnetName = $ResourceGroupName + \"vnet\"\r\n", "$VnetName = $ResourceGroup + \"vnet\"\r\n",
"$PipName = $ResourceGroupName + $(Get-Random)\r\n", "$PipName = $ResourceGroup + $(Get-Random)\r\n",
"\r\n", "\r\n",
"# Create a subnet configuration\r\n", "# Create a subnet configuration\r\n",
"$SubnetConfig = New-AzVirtualNetworkSubnetConfig -Name $SubnetName -AddressPrefix 192.168.1.0/24\r\n", "$SubnetConfig = New-AzVirtualNetworkSubnetConfig -Name $SubnetName -AddressPrefix 192.168.1.0/24\r\n",
"\r\n", "\r\n",
"# Create a virtual network\r\n", "# Create a virtual network\r\n",
"$Vnet = New-AzVirtualNetwork -ResourceGroupName $ResourceGroupName -Location $Location `\r\n", "$Vnet = New-AzVirtualNetwork -ResourceGroupName $ResourceGroup -Location $Location `\r\n",
" -Name $VnetName -AddressPrefix 192.168.0.0/16 -Subnet $SubnetConfig\r\n", " -Name $VnetName -AddressPrefix 192.168.0.0/16 -Subnet $SubnetConfig\r\n",
"\r\n", "\r\n",
"# Create a public IP address and specify a DNS name\r\n", "# Create a public IP address and specify a DNS name\r\n",
"$Pip = New-AzPublicIpAddress -ResourceGroupName $ResourceGroupName -Location $Location `\r\n", "$Pip = New-AzPublicIpAddress -ResourceGroupName $ResourceGroup -Location $Location `\r\n",
" -AllocationMethod Static -IdleTimeoutInMinutes 4 -Name $PipName" " -AllocationMethod Static -IdleTimeoutInMinutes 4 -Name $PipName"
], ],
"metadata": { "metadata": {
@@ -228,8 +215,8 @@
" -DestinationAddressPrefix * -DestinationPortRange 1433 -Access Allow\r\n", " -DestinationAddressPrefix * -DestinationPortRange 1433 -Access Allow\r\n",
"\r\n", "\r\n",
"# Create the network security group\r\n", "# Create the network security group\r\n",
"$NsgName = $ResourceGroupName + \"nsg\"\r\n", "$NsgName = $ResourceGroup + \"nsg\"\r\n",
"$Nsg = New-AzNetworkSecurityGroup -ResourceGroupName $ResourceGroupName `\r\n", "$Nsg = New-AzNetworkSecurityGroup -ResourceGroupName $ResourceGroup `\r\n",
" -Location $Location -Name $NsgName `\r\n", " -Location $Location -Name $NsgName `\r\n",
" -SecurityRules $NsgRuleRDP,$NsgRuleSQL" " -SecurityRules $NsgRuleRDP,$NsgRuleSQL"
], ],
@@ -251,9 +238,9 @@
{ {
"cell_type": "code", "cell_type": "code",
"source": [ "source": [
"$InterfaceName = $ResourceGroupName + \"int\"\r\n", "$InterfaceName = $ResourceGroup + \"int\"\r\n",
"$Interface = New-AzNetworkInterface -Name $InterfaceName `\r\n", "$Interface = New-AzNetworkInterface -Name $InterfaceName `\r\n",
" -ResourceGroupName $ResourceGroupName -Location $Location `\r\n", " -ResourceGroupName $ResourceGroup -Location $Location `\r\n",
" -SubnetId $VNet.Subnets[0].Id -PublicIpAddressId $Pip.Id `\r\n", " -SubnetId $VNet.Subnets[0].Id -PublicIpAddressId $Pip.Id `\r\n",
" -NetworkSecurityGroupId $Nsg.Id" " -NetworkSecurityGroupId $Nsg.Id"
], ],
@@ -287,29 +274,6 @@
"outputs": [], "outputs": [],
"execution_count": null "execution_count": null
}, },
{
"cell_type": "markdown",
"source": [
"### Appendix: Azure SQL VM Offers\r\n",
"Run the following command to get updated list of offers for Microsoft SQL Server in your location. These settings can be used for the OfferName associated with this migration. Configure it for your purposes.\r\n",
"\r\n",
"Note that the SQL Version is first then appended with an operating system version. E.g.: \"WS2019\" means Windows Server 2019. Along with various versions of Windows Servers, there are also enterprise Linux versions such as RedHat Enterprise, Suse Enterprise, and Ubuntu. Some versions are BYOL (Bring Your Own License) aka <a href=\"https://azure.microsoft.com/en-us/pricing/hybrid-benefit/\">Hybrid Benefit</a>."
],
"metadata": {
"azdata_cell_guid": "ce2daf93-7c20-4073-babc-53c9187e5691"
}
},
{
"cell_type": "code",
"source": [
"Get-AzVMImageOffer -Location $Location -Publisher $PublisherName | Select Offer"
],
"metadata": {
"azdata_cell_guid": "e5808cbf-e6c6-4abe-8e1b-3c282bc7667c"
},
"outputs": [],
"execution_count": null
},
{ {
"cell_type": "markdown", "cell_type": "markdown",
"source": [ "source": [
@@ -327,9 +291,7 @@
"$VMConfig = New-AzVMConfig -VMName $VMName -VMSize Standard_DS13_V2 |\r\n", "$VMConfig = New-AzVMConfig -VMName $VMName -VMSize Standard_DS13_V2 |\r\n",
" Set-AzVMOperatingSystem -Windows -ComputerName $VMName -Credential $Cred -ProvisionVMAgent -EnableAutoUpdate |\r\n", " Set-AzVMOperatingSystem -Windows -ComputerName $VMName -Credential $Cred -ProvisionVMAgent -EnableAutoUpdate |\r\n",
" Set-AzVMSourceImage -PublisherName \"MicrosoftSQLServer\" -Offer \"SQL2017-WS2016\" -Skus \"SQLDEV\" -Version \"latest\" |\r\n", " Set-AzVMSourceImage -PublisherName \"MicrosoftSQLServer\" -Offer \"SQL2017-WS2016\" -Skus \"SQLDEV\" -Version \"latest\" |\r\n",
" Add-AzVMNetworkInterface -Id $Interface.Id\r\n", " Add-AzVMNetworkInterface -Id $Interface.Id"
"\r\n",
""
], ],
"metadata": { "metadata": {
"azdata_cell_guid": "6625d7b2-6c97-432e-b5f5-be4ca93017ae" "azdata_cell_guid": "6625d7b2-6c97-432e-b5f5-be4ca93017ae"
@@ -350,7 +312,7 @@
"cell_type": "code", "cell_type": "code",
"source": [ "source": [
"# Create the VM\r\n", "# Create the VM\r\n",
"New-AzVM -ResourceGroupName $ResourceGroupName -Location $Location -VM $VMConfig" "New-AzVM -ResourceGroupName $ResourceGroup -Location $Location -VM $VMConfig"
], ],
"metadata": { "metadata": {
"azdata_cell_guid": "05fa1f3d-94e1-480f-ad20-d3006bafc6ac" "azdata_cell_guid": "05fa1f3d-94e1-480f-ad20-d3006bafc6ac"
@@ -371,7 +333,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"source": [ "source": [
"Set-AzVMSqlServerExtension -ResourceGroupName $ResourceGroupName -VMName $VMName -name \"SQLIaasExtension\" -version \"2.0\" -Location $Location" "Set-AzVMSqlServerExtension -ResourceGroupName $ResourceGroup -VMName $VMName -name \"SQLIaasExtension\" -version \"2.0\" -Location $Location"
], ],
"metadata": { "metadata": {
"azdata_cell_guid": "bb3b5436-c34b-44b3-b631-ea60c9dcf16a" "azdata_cell_guid": "bb3b5436-c34b-44b3-b631-ea60c9dcf16a"