{"id":9,"date":"2017-01-04T14:58:54","date_gmt":"2017-01-04T20:58:54","guid":{"rendered":"http:\/\/peterod.azurewebsites.net\/?p=9"},"modified":"2017-01-04T14:58:54","modified_gmt":"2017-01-04T20:58:54","slug":"install-sql-server-onto-an-azure-vm-using-powershell-dsc","status":"publish","type":"post","link":"http:\/\/www.perktime.org\/index.php\/2017\/01\/04\/install-sql-server-onto-an-azure-vm-using-powershell-dsc\/","title":{"rendered":"Install SQL Server onto an Azure VM using PowerShell DSC"},"content":{"rendered":"<p>The Azure marketplace has quite a few prebuilt virtual machines with SQL Server already in them from versions SQL Server 2008R2 to SQL Server 2016. You can also use the BYOL versions to provide your own SQL Server license if you prefer. However, you may still wish to have more control over the installation process such as the SQL Server instance name, install location, installed features, etc. I\u2019ve created a GitHub project here:<br \/>\n<a title=\"https:\/\/github.com\/perktime\/InstallSQLServerByDSCForAzure\" href=\"https:\/\/github.com\/perktime\/InstallSQLServerByDSCForAzure\">https:\/\/github.com\/perktime\/InstallSQLServerByDSCForAzure<\/a><br \/>\nThese ARM templates will create a new base Windows VM using an Azure marketplace image, domain join the VM into an existing Windows AD domain and use PowerShell DSC to install SQL Server from Azure Files.<br \/>\nThe DSC uses the xSQLServer PowerShell module from here: <a title=\"https:\/\/github.com\/PowerShell\/xSQLServer\" href=\"https:\/\/github.com\/PowerShell\/xSQLServer\">https:\/\/github.com\/PowerShell\/xSQLServer<\/a> where you will also find additional documentation. Also note that currently not all potential parameters for SQL Server setup are implemented in the ARM template. You could either add them yourself to the ARM templates and SQLInstall.ps1 file or let me know and I might update <img decoding=\"async\" class=\"wlEmoticon wlEmoticon-winkingsmile\" src=\"https:\/\/msdnshared.blob.core.windows.net\/media\/2017\/01\/wlEmoticon-winkingsmile.png\" alt=\"Winking smile\" \/><br \/>\n<strong>Prerequisites<\/strong><br \/>\nBefore you can use this solution, you will need to create a storage account (or use an existing one) and enable Azure Files for it.<br \/>\n1) Go to the Azure portal and create a new storage account:<br \/>\n<a href=\"https:\/\/msdnshared.blob.core.windows.net\/media\/2017\/01\/image130.png\"><img decoding=\"async\" loading=\"lazy\" style=\"border-width: 0px; padding-top: 0px; padding-right: 0px; padding-left: 0px;\" title=\"image\" src=\"https:\/\/msdnshared.blob.core.windows.net\/media\/2017\/01\/image_thumb91.png\" alt=\"image\" width=\"169\" height=\"531\" border=\"0\" \/><\/a><br \/>\n2) Once the storage account is done creating, you will need to create a file share for it. Click Files and then click \u201c+ File Share\u201d<br \/>\n<a href=\"https:\/\/msdnshared.blob.core.windows.net\/media\/2017\/01\/image131.png\"><img decoding=\"async\" loading=\"lazy\" style=\"border-width: 0px; padding-top: 0px; padding-right: 0px; padding-left: 0px;\" title=\"image\" src=\"https:\/\/msdnshared.blob.core.windows.net\/media\/2017\/01\/image_thumb92.png\" alt=\"image\" width=\"761\" height=\"472\" border=\"0\" \/><\/a><br \/>\n3) Supply a name and a quota and click Create<br \/>\n<a href=\"https:\/\/msdnshared.blob.core.windows.net\/media\/2017\/01\/image132.png\"><img decoding=\"async\" loading=\"lazy\" style=\"border-width: 0px; padding-top: 0px; padding-right: 0px; padding-left: 0px;\" title=\"image\" src=\"https:\/\/msdnshared.blob.core.windows.net\/media\/2017\/01\/image_thumb93.png\" alt=\"image\" width=\"251\" height=\"443\" border=\"0\" \/><\/a><br \/>\n4) You will then need to download a version of SQL Server, create a folder for it in Azure Files and copy the SQL Server install files into that folder. You may find it quickest to do this right from an existing Azure VM in the same region to access the Microsoft VLSC site or MSDN or download a copy of SQL Server Developer Edition here: <a title=\"https:\/\/www.microsoft.com\/en-us\/sql-server\/sql-server-editions-developers\" href=\"https:\/\/www.microsoft.com\/en-us\/sql-server\/sql-server-editions-developers\">https:\/\/www.microsoft.com\/en-us\/sql-server\/sql-server-editions-developers<\/a>. Note that if you get the ISO, you will need to extract the files out of the ISO as this template currently does not support directly installing from the ISO.<br \/>\n5) You will need to take note of the access key for this storage account as well as the Azure Files URL so that you can supply them to the azuredeploy.parameters.json file. If you click \u201cConnect\u201d on the file share, you can see the Azure Files UNC path as well as click the link for the access keys:<br \/>\n<a href=\"https:\/\/msdnshared.blob.core.windows.net\/media\/2017\/01\/image133.png\"><img decoding=\"async\" loading=\"lazy\" style=\"border-width: 0px; padding-top: 0px; padding-right: 0px; padding-left: 0px;\" title=\"image\" src=\"https:\/\/msdnshared.blob.core.windows.net\/media\/2017\/01\/image_thumb94.png\" alt=\"image\" width=\"1005\" height=\"538\" border=\"0\" \/><\/a><br \/>\n6) Next, you will need to copy the SQLinstall.ps1.zip and DeployWindowsVM.json files into your Azure Blob storage account (note: not in Azure Files). Using a tool like Azure Storage Explorer, copy these 2 files into a blob container that has public read access enabled:<br \/>\n<a href=\"https:\/\/msdnshared.blob.core.windows.net\/media\/2017\/01\/image134.png\"><img decoding=\"async\" loading=\"lazy\" style=\"border-width: 0px; padding-top: 0px; padding-right: 0px; padding-left: 0px;\" title=\"image\" src=\"https:\/\/msdnshared.blob.core.windows.net\/media\/2017\/01\/image_thumb95.png\" alt=\"image\" width=\"739\" height=\"439\" border=\"0\" \/><\/a><br \/>\n<strong>Updating the azuredeploy.parameters.json file<\/strong><br \/>\nThe azuredeploy.parameters.json file has a number of parameters that you will need to update such as:<br \/>\n<strong>vmName<\/strong>: The computer name of the VM<br \/>\n<strong>vmSize<\/strong>: The desired Azure VM size and series. It is recommended that you use a series that supports SSD storage such as DS, GS or FS.<br \/>\n<strong>assetLocation<\/strong>: The location in Azure blob storage where the SQLInstall.ps1.zip and DeployWindowsVM.json are deployed into an Azure blob storage container with public read access.<br \/>\n<strong>AdminUserName<\/strong>: The local Windows administrator account<br \/>\n<strong>AdminPassword<\/strong>: The local Windows administrator account password<br \/>\n<strong>DomainUserName<\/strong>: The domain username that has domain join permissions<br \/>\n<strong>DomainPassword<\/strong>: The domain user\u2019s password<br \/>\n<strong>existingDomainName<\/strong>: The name of the Windows domain you will be joining<br \/>\n<strong>existingOUPath (optional)<\/strong>: The OU where you want the computer account placed in Active Directory<br \/>\n<strong>existingVirtualNetworkName<\/strong>: The existing Azure virtual network where this VM will be placed<br \/>\n<strong>existingVirtualNetworkResourceGroup: <\/strong>The existing Azure virtual network resource group<br \/>\n<strong>storageAccountUri: <\/strong>The existing Azure blob storage account for this VM\u2019s disks. Premium storage is recommended for SQL Server<br \/>\n<strong>bootdiagnosticsstorageAccountUri: <\/strong>The existing Azure blob storage account for boot diagnostics. Must be standard storage<br \/>\n<strong>windowsOSVersion: <\/strong>The version of Windows Server to use for the VM. Note that not all versions of SQL Server may be supported on all versions of Windows Server<br \/>\n<strong>subnetName: <\/strong>The existing subnet name where this VM will be placed<br \/>\n<strong>FileShareUserName: <\/strong>The Azure Files username. It should be the same as the first part of the Azure Files UNC path (e.g. if your Azure Files is <a href=\"\/\/\\\\peteazurefiles.file.core.windows.net\">\\\\peteazurefiles.file.core.windows.net<\/a> then the username would be azurefiles<br \/>\n<strong>FileSharePassword: <\/strong>The Azure Files access key.<br \/>\n<strong>InstallDir: <\/strong>The folder where the SQL Server files are located (e.g. sql2016). It is not the full path<br \/>\n<strong>PackagePath: <\/strong>The path to Azure Files directory where the SQL Server install files are location (e.g. <a href=\"\/\/\\\\peteazurefiles.file.core.windows.net\\installs\">\\\\\\\\peteazurefiles.file.core.windows.net\\\\installs<\/a>\u201d)<br \/>\n<strong>location: <\/strong>The Azure data center location you wish to use<br \/>\n<strong>SQLAgentUserName: <\/strong>The domain\\username for the SQL Agent account<br \/>\n<strong>SQLAgentPassword: <\/strong>The password for the SQL Agent account<br \/>\n<strong>SQLSAAccountPassword: <\/strong>The SQL SA Account password<br \/>\n<strong>SQLServiceUserName: <\/strong>The domain\\username for the SQLService account<br \/>\n<strong>SQLServicePassword: <\/strong>The password for the SQLService account<br \/>\n<strong>Features: <\/strong>The installed features for SQL Server (SQLENGINE,FULLTEXT). Note that not all versions of SQL Server support the same features.<br \/>\n<strong>UpdateSource: <\/strong>This is the location where SQL Server setup searches for product updates. Use \u201cMU\u201d if you want to have SQL Server use Windows Update.<br \/>\n<strong>UpdateEnabled: <\/strong>This determines if SQL Server should update itself or not. Can be true or false.<br \/>\n<strong>InstallSharedDir: <\/strong>The installation path for shared SQL Files<br \/>\n<strong>InstallSharedWOWDir: <\/strong>The installation path for x86 shared SQL files<br \/>\n<strong>SQLInstanceName: <\/strong>The name of the SQL Instance<br \/>\n<strong>SQLInstanceDir: <\/strong>The installation path for the SQL instance files<br \/>\n<strong>SecurityMode: <\/strong>The SQL Security mode (either Windows or SQL). SQL is also known as Mixed Mode<br \/>\n<strong>SQLSysAdminAccounts: <\/strong>Array of accounts to be made SQL administrators.<br \/>\n&nbsp;<br \/>\n<strong>Troubleshooting<\/strong><br \/>\nIn the event that your deployment fails and it\u2019s because of an invalid parameter, Azure may not provide a helpful error message in this case and you may see this:<br \/>\n<a href=\"https:\/\/msdnshared.blob.core.windows.net\/media\/2017\/01\/image135.png\"><img decoding=\"async\" loading=\"lazy\" style=\"border-width: 0px; padding-top: 0px; padding-right: 0px; padding-left: 0px;\" title=\"image\" src=\"https:\/\/msdnshared.blob.core.windows.net\/media\/2017\/01\/image_thumb96.png\" alt=\"image\" width=\"1150\" height=\"200\" border=\"0\" \/><\/a><br \/>\nIf this occurs, your best bet is to look at the SQL Server log file (e.g. \u201cC:\\Program Files\\Microsoft SQL Server\\130\\Setup Bootstrap\\Log\\Summary.txt\u201d)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The Azure marketplace has quite a few prebuilt virtual machines with SQL Server already in them from versions SQL Server 2008R2 to SQL Server 2016. You can also use the BYOL versions to provide your own SQL Server license if you prefer. However, you may still wish to have more control over the installation process &hellip; <\/p>\n<p class=\"link-more\"><a href=\"http:\/\/www.perktime.org\/index.php\/2017\/01\/04\/install-sql-server-onto-an-azure-vm-using-powershell-dsc\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Install SQL Server onto an Azure VM using PowerShell DSC&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"_links":{"self":[{"href":"http:\/\/www.perktime.org\/index.php\/wp-json\/wp\/v2\/posts\/9"}],"collection":[{"href":"http:\/\/www.perktime.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.perktime.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.perktime.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.perktime.org\/index.php\/wp-json\/wp\/v2\/comments?post=9"}],"version-history":[{"count":0,"href":"http:\/\/www.perktime.org\/index.php\/wp-json\/wp\/v2\/posts\/9\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.perktime.org\/index.php\/wp-json\/wp\/v2\/media?parent=9"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.perktime.org\/index.php\/wp-json\/wp\/v2\/categories?post=9"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.perktime.org\/index.php\/wp-json\/wp\/v2\/tags?post=9"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}