From fd1d974a24e4d2881d924f3ff972cc7c25aefde1 Mon Sep 17 00:00:00 2001 From: "Alexander (Sasha) Nosov" Date: Wed, 3 Jul 2024 23:33:24 -0700 Subject: [PATCH 01/22] Update install-payg-sql-server.ps1 Added volume mounting and key extraction --- .../install-payg-sql-server.ps1 | 55 +++++++++++-------- 1 file changed, 31 insertions(+), 24 deletions(-) diff --git a/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/install-payg-sql-server.ps1 b/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/install-payg-sql-server.ps1 index 6ff5d8f1..4bb0bddf 100644 --- a/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/install-payg-sql-server.ps1 +++ b/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/install-payg-sql-server.ps1 @@ -14,13 +14,9 @@ param ( [Parameter (Mandatory=$true)] [string]$SqlServerSvcPassword, [Parameter (Mandatory=$true)] - [string]$SqlServerVersion, - [Parameter (Mandatory=$true)] [string]$SqlServerEdition, [Parameter (Mandatory=$true)] - [string]$SqlServerProductKey, - [Parameter (Mandatory=$true)] - [string]$isoURL + [string]$isoFolder ) # This function checks if the specified module is imported into the session and if not installes and/or imports it @@ -125,24 +121,38 @@ try { New-AzConnectedMachine -ResourceGroupName $AzureResourceGroupUri -Name $hostName -Location $AzureRegion - # Step 4: Automatically download installable media + # Step 4: Retrieve the product key - $isoLocation = "C:\download\SQLServer.iso" - if (!(Test-Path -Path $isoLocation)) { - $freeSpace = (Get-PSDrive -Name C).Free - $isoSize = (Invoke-WebRequest -Uri $isoURL -Method Head).Headers.'Content-Length' - if ($freeSpace -gt $isoSize) { - Start-BitsTransfer -Source $isoURL -Destination $isoLocation - } else { - throw "Not enough free space to download the ISO." - } + $keyFiles = Get-ChildItem $isoFolder -Filter "*.txt" + + foreach ($keyFile in $keyFiles) { + # Read each line from the file + Get-Content $keyFile | ForEach-Object { + if ($_ -match "(?i)$($SqlServerEdition)" -and $_ -match "[A-Z0-9]{5,}-[A-Z0-9]{5,}-[A-Z0-9]{5,}-[A-Z0-9]{5,}-[A-Z0-9]{5,}.*") { + # Extract the product key (including any following string after a space) + $productKey = [regex]::Match($_, '[A-Z0-9]{5,}-[A-Z0-9]{5,}-[A-Z0-9]{5,}-[A-Z0-9]{5,}-[A-Z0-9]{5,}.*').Value + # Strip any text after the product key + $productKey = $productKey -replace " .*$" + Write-Host "Found product key in $($keyFile.Name): $productKey" + } + } } # Step 5: Mount the ISO file as a volume - $volumeInfo = Mount-DiskImage -ImagePath $isoLocation -PassThru | Get-Volume + $isoFiles = Get-ChildItem $isoFolder -Filter "*.iso" + + foreach ($isoFile in $isoFiles) { + # Mount the ISO file + $mountResult = Mount-DiskImage -ImagePath $isoFile.FullName + $driveLetter = ($mountResult | Get-Volume).DriveLetter + $mountedIsoFile = $isoFile + Write-Host "ISO file $($isoFile.Name) mounted as drive $driveLetter" + break + } + # Step 6: Run unattended SQL Server setup from the mounted volume - $setupPath = ($volumeInfo.DriveLetter + ":\setup.exe") + $setupPath = ($driveLetter + ":\setup.exe") $argumentList = " /q /ACTION=Install @@ -154,7 +164,7 @@ try { /AGTSVCACCOUNT='$($SqlServerSvcAccount)' /AGTSVCPASSWORD='$($SqlServerSvcPassword)' /IACCEPTSQLSERVERLICENSETERMS - /PID='$($SqlServerProductKey)' + /PID='$($productKey)' /Edition='$($SqlServerEdition)' " if ($SqlServerInstanceName) { @@ -172,13 +182,10 @@ try { } New-AzConnectedMachineExtension -ResourceGroupName $AzureResourceGroupUri -MachineName $hostName -Name "WindowsAgent.SqlServer" -Publisher "Microsoft.AzureData" -Type "WindowsAgent.SqlServer" -TypeHandlerVersion "1.0" -Settings $settings - # Step 9: Dismount the ISO file after installation - Dismount-DiskImage -ImagePath $isoLocation + # Step 8: Dismount the ISO file after installation + Dismount-DiskImage -ImagePath $isoFolder + $mountedIsoFile - # Step 10: Remove the media from the local file system - Remove-Item -Path $isoLocation - - # Step 8: Display the status of the Azure resource for Arc-enabled SQL Server + # Step 9: Display the status of the Azure resource for Arc-enabled SQL Server $query = " resources | where type =~ 'microsoft.hybridcompute/machines' From df79461986a0a1e5e2d18ec8e6bc61f73dc1d58a Mon Sep 17 00:00:00 2001 From: "Alexander (Sasha) Nosov" Date: Fri, 5 Jul 2024 17:05:23 -0700 Subject: [PATCH 02/22] Modified to remove downloading the image file --- .../install-payg-sql-server.ps1 | 186 ++++++++++++------ 1 file changed, 131 insertions(+), 55 deletions(-) diff --git a/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/install-payg-sql-server.ps1 b/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/install-payg-sql-server.ps1 index 4bb0bddf..7f78eda0 100644 --- a/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/install-payg-sql-server.ps1 +++ b/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/install-payg-sql-server.ps1 @@ -2,7 +2,7 @@ param ( [Parameter (Mandatory=$true)] [string]$AzureSubscriptionId, [Parameter (Mandatory=$true)] - [string]$AzureResourceGroupUri, + [string]$AzureResourceGroup, [Parameter (Mandatory=$true)] [string]$AzureRegion, [Parameter (Mandatory=$false)] @@ -16,7 +16,9 @@ param ( [Parameter (Mandatory=$true)] [string]$SqlServerEdition, [Parameter (Mandatory=$true)] - [string]$isoFolder + [string]$IsoFolder, + [Parameter (Mandatory=$false)] + [string]$Proxy ) # This function checks if the specified module is imported into the session and if not installes and/or imports it @@ -49,7 +51,7 @@ function LoadModule # If module is not imported, not available on disk, but is in online gallery then install and import if (Find-Module -Name $name) { - Install-Module -Name $name -Force -Verbose -Scope CurrentUser + Install-Module -Name $name -Force -Scope CurrentUser try { Import-Module $name -ErrorAction SilentlyContinue @@ -75,7 +77,8 @@ function LoadModule try { - #Step 0: Ensure PS version and load missing Azure modules + write-host "==== Ensure PS version and load missing Azure modules ====" + # # Suppress warnings # @@ -89,41 +92,55 @@ try { "Az.ResourceGraph" ) $requiredModules | Foreach-Object {LoadModule $_} + + write-host "==== Check if setup.exe is already running and kill it if so ====" - # Step 1: Check if setup.exe is already running and kill it if so if (Get-Process setup -ErrorAction SilentlyContinue) { Stop-Process -Name setup -Force Write-Host "Existing setup.exe process terminated." } - # Step 2: Log in to Azure - Connect-AzAccount + write-host "==== Log in to Azure ====" + + Connect-AzAccount | Out-Null $subscription = Get-AzSubscription -SubscriptionId $AzureSubscriptionId -ErrorAction SilentlyContinue if (-not $subscription) { Write-Error "Azure subscription with ID '$AzureSubscriptionId' does not exist." exit } + Set-AzContext -Subscription $AzureSubscriptionId | Out-Null - # Step 2: Block auto-onboarding to Arc by tagging the resource group - $existingResourceGroup = Get-AzResourceGroup -Name $AzureResourceGroupUri -ErrorAction SilentlyContinue + write-host "==== Block auto-onboarding to Arc ====" + + $existingResourceGroup = Get-AzResourceGroup -Name $AzureResourceGroup -ErrorAction SilentlyContinue if ($existingResourceGroup) { - Write-Host "Resource group '$AzureResourceGroupUri' exists." + $tags = @{"ArcOnboarding" = "Blocked"} + Set-AzResourceGroup -Name $AzureResourceGroup -Tag $tags | Out-Null } else { - Write-Error "Resource group '$AzureResourceGroupUri' does not exist." + Write-Error "Resource group '$AzureResourceGroup' does not exist." exit } - $tags = @{"ArcOnboarding" = "Blocked"} - Set-AzResourceGroup -Name $AzureResourceGroupUri -Tag $tags - # Step 3: Onboard the VM to Azure Arc - $hostName = (Get-WmiObject Win32_ComputerSystem).Name + write-host "==== Mount the ISO file as a volume ====" - New-AzConnectedMachine -ResourceGroupName $AzureResourceGroupUri -Name $hostName -Location $AzureRegion + $isoFiles = Get-ChildItem $IsoFolder -Filter "*.iso" - # Step 4: Retrieve the product key + foreach ($isoFile in $isoFiles) { + # Mount the ISO file + $imagePath = $isoFile.FullName + $mountResult = Mount-DiskImage -ImagePath $imagePath + $driveLetter = ($mountResult | Get-Volume).DriveLetter + Write-Host "ISO file $($isoFile.Name) mounted as drive $($driveLetter):" + break + } + + + write-host "==== Run unattended SQL Server setup from the mounted volume ====" + + # Retrieve the product key - $keyFiles = Get-ChildItem $isoFolder -Filter "*.txt" + $keyFiles = Get-ChildItem $IsoFolder -Filter "*.txt" foreach ($keyFile in $keyFiles) { # Read each line from the file @@ -133,25 +150,12 @@ try { $productKey = [regex]::Match($_, '[A-Z0-9]{5,}-[A-Z0-9]{5,}-[A-Z0-9]{5,}-[A-Z0-9]{5,}-[A-Z0-9]{5,}.*').Value # Strip any text after the product key $productKey = $productKey -replace " .*$" - Write-Host "Found product key in $($keyFile.Name): $productKey" } } } - # Step 5: Mount the ISO file as a volume - $isoFiles = Get-ChildItem $isoFolder -Filter "*.iso" + # Launch setup - foreach ($isoFile in $isoFiles) { - # Mount the ISO file - $mountResult = Mount-DiskImage -ImagePath $isoFile.FullName - $driveLetter = ($mountResult | Get-Volume).DriveLetter - $mountedIsoFile = $isoFile - Write-Host "ISO file $($isoFile.Name) mounted as drive $driveLetter" - break - } - - - # Step 6: Run unattended SQL Server setup from the mounted volume $setupPath = ($driveLetter + ":\setup.exe") $argumentList = " /q @@ -172,45 +176,117 @@ try { } Start-Process -FilePath $setupPath -ArgumentList $argumentList + + write-host "==== Dismount the ISO file after installation ====" - # Step 7: Install SQL Arc extension with LT=PAYG + Dismount-DiskImage -ImagePath $imagePath | Out-Null + + write-host "==== Onboard the VM to Azure Arc ====" + + $hostName = (Get-WmiObject Win32_ComputerSystem).Name + + if ($Proxy) { + Connect-AzConnectedMachine -ResourceGroupName $AzureResourceGroup -Name $hostName -Location $AzureRegion -Proxi $Proxy | Out-Null + } else { + Connect-AzConnectedMachine -ResourceGroupName $AzureResourceGroup -Name $hostName -Location $AzureRegion | Out-Null + } + + write-host "==== Install SQL Arc extension with LT=PAYG and upgrade to the latest version ====" + + $extensionName = "WindowsAgent.SqlServer" $Settings = @{ SqlManagement = @{ IsEnabled = $true }; LicenseType = "PAYG"; enableExtendedSecurityUpdates = $True; esuLastUpdatedTimestamp = [DateTime]::UtcNow.ToString('yyyy-MM-ddTHH:mm:ss.fffZ') } - New-AzConnectedMachineExtension -ResourceGroupName $AzureResourceGroupUri -MachineName $hostName -Name "WindowsAgent.SqlServer" -Publisher "Microsoft.AzureData" -Type "WindowsAgent.SqlServer" -TypeHandlerVersion "1.0" -Settings $settings + New-AzConnectedMachineExtension -ResourceGroupName $AzureResourceGroup -MachineName $hostName -Name "Microsoft.AzureData" -Publisher "Microsoft.AzureData" -ExtensionType "WindowsAgent.SqlServer" -Location $AzureRegion -Settings $Settings -EnableAutomaticUpgrade - # Step 8: Dismount the ISO file after installation - Dismount-DiskImage -ImagePath $isoFolder + $mountedIsoFile + # Step 10: Display the status of the Azure resource for Arc-enabled SQL Server + write-host "==== Display the status of the billable Arc-enabled host ====" - # Step 9: Display the status of the Azure resource for Arc-enabled SQL Server $query = " resources - | where type =~ 'microsoft.hybridcompute/machines' - | where resourceGroup =~ '$($AzureResourceGroupUri)' - | where properties.detectedProperties.mssqldiscovered == 'true' - | extend machineIdHasSQLServerDiscovered = id - | project name, machineIdHasSQLServerDiscovered, resourceGroup, subscriptionId - | join kind= leftouter ( - resources - | where type == 'microsoft.hybridcompute/machines/extensions' | where properties.type in ('WindowsAgent.SqlServer','LinuxAgent.SqlServer') - | extend machineIdHasSQLServerExtensionInstalled = iff(id contains '/extensions/WindowsAgent.SqlServer' or id contains '/extensions/LinuxAgent.SqlServer', substring(id, 0, indexof(id, '/extensions/')), '') - | project Extension_State = properties.provisioningState, - License_Type = properties.settings.LicenseType, - ESU = iff(notnull(properties.settings.enableExtendedSecurityUpdates), iff(properties.settings.enableExtendedSecurityUpdates == true,'enabled','disabled'), ''), - Extension_Version = properties.instanceView.typeHandlerVersion, - machineIdHasSQLServerExtensionInstalled)on $left.machineIdHasSQLServerDiscovered == $right.machineIdHasSQLServerExtensionInstalled - | where isnotempty(machineIdHasSQLServerExtensionInstalled) - | project-away machineIdHasSQLServerDiscovered, machineIdHasSQLServerExtensionInstalled + | where type =~ 'Microsoft.HybridCompute/machines' + | where subscriptionId =~ '$($AzureSubscriptionId)' + | where resourceGroup =~ '$($AzureResourceGroup)' + | extend status = tostring(properties.status) + | where status =~ 'Connected' + | extend machineID = tolower(id) + | extend VMbyManufacturer = toboolean(iff(properties.detectedProperties.manufacturer in ( + 'VMware', + 'QEMU', + 'Amazon EC2', + 'OpenStack', + 'Hetzner', + 'Mission Critical Cloud', + 'DigitalOcean', + 'UpCloud', + 'oVirt', + 'Alibaba', + 'KubeVirt', + 'Parallels', + 'XEN' + ), 1, 0)) + | extend VMbyModel = toboolean(iff(properties.detectedProperties.model in ( + 'OpenStack', + 'Droplet', + 'oVirt', + 'Hypervisor', + 'Virtual', + 'BHYVE', + 'KVM' + ), 1, 0)) + | extend GoogleVM = toboolean(iff((properties.detectedProperties.manufacturer =~ 'Google') and (properties.detectedProperties.model =~ 'Google Compute Engine'), 1, 0)) + | extend NutanixVM = toboolean(iff((properties.detectedProperties.manufacturer =~ 'Nutanix') and (properties.detectedProperties.model =~ 'AHV'), 1, 0)) + | extend MicrosoftVM = toboolean(iff((properties.detectedProperties.manufacturer =~ 'Microsoft Corporation') and (properties.detectedProperties.model =~ 'Virtual Machine'), 1, 0)) + | extend billableCores = iff(VMbyManufacturer or VMbyModel or GoogleVM or NutanixVM or MicrosoftVM, properties.detectedProperties.logicalCoreCount, properties.detectedProperties.coreCount) + | join kind = leftouter // Join Extension + ( + resources + | where type =~ 'Microsoft.HybridCompute/machines/extensions' + | where name == 'WindowsAgent.SqlServer' or name == 'LinuxAgent.SqlServer' + | extend extMachineID = substring(id, 0, indexof(id, '/extensions')) + | extend extensionId = id + ) + on `$left.id == `$right.extMachineID + | join kind = inner // Join SQL Arc + ( + resources + | where type =~ 'microsoft.azurearcdata/sqlserverinstances' + | extend sqlVersion = tostring(properties.version) + | extend sqlEdition = tostring(properties.edition) + | extend is_Enterprise = toint(iff(sqlEdition == 'Enterprise', 1, 0)) + | extend sqlStatus = tostring(properties.status) + | extend licenseType = tostring(properties.licenseType) + | where sqlEdition in ('Enterprise', 'Standard') + | where licenseType !~ 'HADR' + | where sqlStatus =~ 'Connected' + | extend ArcServer = tolower(tostring(properties.containerResourceId)) + | order by sqlEdition + ) + on `$left.machineID == `$right.ArcServer + | where isnotnull(extensionId) + | summarize Edition = iff(sum(is_Enterprise) > 0, 'Enterprise', 'Standard') by machineID + , name + , resourceGroup + , subscriptionId + , Model = tostring(properties.detectedProperties.model) + , Manufacturer = tostring(properties.detectedProperties.manufacturer) + , License_Type = tostring(properties1.settings.LicenseType) + , OS = tostring(properties.osName) + , Uses_UV = tostring(properties1.settings.UsePhysicalCoreLicense.IsApplied) + , Cores = tostring(billableCores) + , Version = sqlVersion + | project-away machineID + | order by Edition, name asc " - Search-AzGraph -Query "$($query)" + Search-AzGraph -Query $query } catch { Write-Error "An error occurred: $_" # You can add additional error handling logic here } finally { # Cleanup or other actions that should always run - Write-Host "Script execution completed." + Write-Host "==== Installation completed ====" } From 29be53596f8d988f7e32f4f38a5b951c60a5bd81 Mon Sep 17 00:00:00 2001 From: "Alexander (Sasha) Nosov" Date: Sat, 6 Jul 2024 09:08:23 -0700 Subject: [PATCH 03/22] Make disk mount idempotant --- .../install-payg-sql-server.ps1 | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/install-payg-sql-server.ps1 b/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/install-payg-sql-server.ps1 index 7f78eda0..6f8e40c5 100644 --- a/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/install-payg-sql-server.ps1 +++ b/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/install-payg-sql-server.ps1 @@ -128,8 +128,12 @@ try { foreach ($isoFile in $isoFiles) { # Mount the ISO file - $imagePath = $isoFile.FullName - $mountResult = Mount-DiskImage -ImagePath $imagePath + $imagePath = $isoFile.FullName + if (!(Get-DiskImage -ImagePath $imagePath).Attached) { + $mountResult = Mount-DiskImage -ImagePath $imagePath + } else { + $mountResult = Get-DiskImage -ImagePath $imagePath + } $driveLetter = ($mountResult | Get-Volume).DriveLetter Write-Host "ISO file $($isoFile.Name) mounted as drive $($driveLetter):" break @@ -186,9 +190,9 @@ try { $hostName = (Get-WmiObject Win32_ComputerSystem).Name if ($Proxy) { - Connect-AzConnectedMachine -ResourceGroupName $AzureResourceGroup -Name $hostName -Location $AzureRegion -Proxi $Proxy | Out-Null + Connect-AzConnectedMachine -ResourceGroupName $AzureResourceGroup -Name $hostName -Location $AzureRegion -Proxi $Proxy | Out-Null } else { - Connect-AzConnectedMachine -ResourceGroupName $AzureResourceGroup -Name $hostName -Location $AzureRegion | Out-Null + Connect-AzConnectedMachine -ResourceGroupName $AzureResourceGroup -Name $hostName -Location $AzureRegion | Out-Null } write-host "==== Install SQL Arc extension with LT=PAYG and upgrade to the latest version ====" From 80e7b2757f2681a56b70bab6da39e3dc4346a270 Mon Sep 17 00:00:00 2001 From: "Alexander (Sasha) Nosov" Date: Sat, 6 Jul 2024 09:51:19 -0700 Subject: [PATCH 04/22] Removed /Edition --- .../install-payg-sql-server.ps1 | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/install-payg-sql-server.ps1 b/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/install-payg-sql-server.ps1 index 6f8e40c5..b072f385 100644 --- a/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/install-payg-sql-server.ps1 +++ b/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/install-payg-sql-server.ps1 @@ -163,17 +163,16 @@ try { $setupPath = ($driveLetter + ":\setup.exe") $argumentList = " /q - /ACTION=Install + /ACTION=`"Install`" /FEATURES=SQL /INSTANCEDIR=C:\SQL - /SQLSYSADMINACCOUNTS='$($SqlServerAdminAccounts)' - /SQLSVCACCOUNT='$($SqlServerSvcAccount)' - /SQLSVCPASSWORD='$($SqlServerSvcPassword)' - /AGTSVCACCOUNT='$($SqlServerSvcAccount)' - /AGTSVCPASSWORD='$($SqlServerSvcPassword)' + /SQLSYSADMINACCOUNTS=`"$($SqlServerAdminAccounts)`" + /SQLSVCACCOUNT=`"$($SqlServerSvcAccount)`" + /SQLSVCPASSWORD=`"$($SqlServerSvcPassword)`" + /AGTSVCACCOUNT=`"$($SqlServerSvcAccount)`" + /AGTSVCPASSWORD=`"$($SqlServerSvcPassword)`" /IACCEPTSQLSERVERLICENSETERMS - /PID='$($productKey)' - /Edition='$($SqlServerEdition)' + /PID=`"$($productKey)`" " if ($SqlServerInstanceName) { $argumentList += "/INSTANCENAME='$($SqlServerInstanceName)'" From 39346584cf5ac10dc5ed704c80d4e8de5a12454f Mon Sep 17 00:00:00 2001 From: "Alexander (Sasha) Nosov" Date: Tue, 9 Jul 2024 18:05:09 -0700 Subject: [PATCH 05/22] Modified to support prePIDed .iso --- .../install-payg-sql-server.ps1 | 76 ++++++++++++------- 1 file changed, 47 insertions(+), 29 deletions(-) diff --git a/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/install-payg-sql-server.ps1 b/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/install-payg-sql-server.ps1 index b072f385..7c9aece8 100644 --- a/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/install-payg-sql-server.ps1 +++ b/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/install-payg-sql-server.ps1 @@ -7,14 +7,16 @@ param ( [string]$AzureRegion, [Parameter (Mandatory=$false)] [string]$SqlServerInstanceName, - [Parameter (Mandatory=$true)] - [string]$SqlServerAdminAccounts, - [Parameter (Mandatory=$true)] - [string]$SqlServerSvcAccount, - [Parameter (Mandatory=$true)] + [Parameter (Mandatory=$false)] + [string]$SqlServerAdminAccounts = "BUILTIN\ADMINISTRATORS", + [Parameter (Mandatory=$false)] + [string]$SqlServerSvcAccount = "NT AUTHORITY\SYSTEM", + [Parameter (Mandatory=$false)] [string]$SqlServerSvcPassword, + [Parameter (Mandatory=$false)] + [string]$AgtServerSvcAccount = "NT AUTHORITY\NETWORK SERVICE", [Parameter (Mandatory=$true)] - [string]$SqlServerEdition, + [string]$AgtServerEdition, [Parameter (Mandatory=$true)] [string]$IsoFolder, [Parameter (Mandatory=$false)] @@ -124,11 +126,31 @@ try { write-host "==== Mount the ISO file as a volume ====" + # Retrieve the product key if any + + $keyFiles = Get-ChildItem $IsoFolder -Filter "*.txt" + + foreach ($keyFile in $keyFiles) { + # Read each line from the file + Get-Content $keyFile | ForEach-Object { + if ($_ -match "(?i)$($SqlServerEdition)" -and $_ -match "[A-Z0-9]{5,}-[A-Z0-9]{5,}-[A-Z0-9]{5,}-[A-Z0-9]{5,}-[A-Z0-9]{5,}.*") { + # Extract the product key (including any following string after a space) + $productKey = [regex]::Match($_, '[A-Z0-9]{5,}-[A-Z0-9]{5,}-[A-Z0-9]{5,}-[A-Z0-9]{5,}-[A-Z0-9]{5,}.*').Value + # Strip any text after the product key + $productKey = $productKey -replace " .*$" + } + } + } + $isoFiles = Get-ChildItem $IsoFolder -Filter "*.iso" + # Pick the .iso file and mount + + $noKeylist = "SQLFULL_ENU_ENTVL", "SQLFULL_ENU_STDVL", "SQLServer2022-x64-ENU-Ent", "SQLServer2022-x64-ENU-Std" + foreach ($isoFile in $isoFiles) { - # Mount the ISO file - $imagePath = $isoFile.FullName + $imagePath = $isoFile.FullName + if ($noKeylist -contains $isoFile.Name) {$productKey = ""} if (!(Get-DiskImage -ImagePath $imagePath).Attached) { $mountResult = Mount-DiskImage -ImagePath $imagePath } else { @@ -142,21 +164,7 @@ try { write-host "==== Run unattended SQL Server setup from the mounted volume ====" - # Retrieve the product key - - $keyFiles = Get-ChildItem $IsoFolder -Filter "*.txt" - - foreach ($keyFile in $keyFiles) { - # Read each line from the file - Get-Content $keyFile | ForEach-Object { - if ($_ -match "(?i)$($SqlServerEdition)" -and $_ -match "[A-Z0-9]{5,}-[A-Z0-9]{5,}-[A-Z0-9]{5,}-[A-Z0-9]{5,}-[A-Z0-9]{5,}.*") { - # Extract the product key (including any following string after a space) - $productKey = [regex]::Match($_, '[A-Z0-9]{5,}-[A-Z0-9]{5,}-[A-Z0-9]{5,}-[A-Z0-9]{5,}-[A-Z0-9]{5,}.*').Value - # Strip any text after the product key - $productKey = $productKey -replace " .*$" - } - } - } + # Launch setup @@ -168,16 +176,26 @@ try { /INSTANCEDIR=C:\SQL /SQLSYSADMINACCOUNTS=`"$($SqlServerAdminAccounts)`" /SQLSVCACCOUNT=`"$($SqlServerSvcAccount)`" - /SQLSVCPASSWORD=`"$($SqlServerSvcPassword)`" /AGTSVCACCOUNT=`"$($SqlServerSvcAccount)`" - /AGTSVCPASSWORD=`"$($SqlServerSvcPassword)`" /IACCEPTSQLSERVERLICENSETERMS - /PID=`"$($productKey)`" " - if ($SqlServerInstanceName) { - $argumentList += "/INSTANCENAME='$($SqlServerInstanceName)'" + if ($SqlServerSvcPassword) { + $argumentList += " /SQLSVCPASSWORD=`"$($SqlServerSvcPassword)`" + " } - + if ($AgtServerSvcPassword) { + $argumentList += " /SQLAGTPASSWORD=`"$($AgtServerSvcPassword)`" + " + } + if ($SqlServerInstanceName) { + $argumentList += " /INSTANCENAME=`"$($SqlServerInstanceName) `" + " + } + if ($productKey) { + $argumentList += " /PID=`"$($productKey)`" + " + } + $argumentList Start-Process -FilePath $setupPath -ArgumentList $argumentList write-host "==== Dismount the ISO file after installation ====" From 2c0c27ecc7cc76950320ee2113b55094d4cce6c3 Mon Sep 17 00:00:00 2001 From: "Alexander (Sasha) Nosov" Date: Tue, 9 Jul 2024 18:17:35 -0700 Subject: [PATCH 06/22] Removed Edition parameter --- .../install-payg-sql-server/install-payg-sql-server.ps1 | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/install-payg-sql-server.ps1 b/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/install-payg-sql-server.ps1 index 7c9aece8..769bfd4d 100644 --- a/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/install-payg-sql-server.ps1 +++ b/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/install-payg-sql-server.ps1 @@ -16,8 +16,6 @@ param ( [Parameter (Mandatory=$false)] [string]$AgtServerSvcAccount = "NT AUTHORITY\NETWORK SERVICE", [Parameter (Mandatory=$true)] - [string]$AgtServerEdition, - [Parameter (Mandatory=$true)] [string]$IsoFolder, [Parameter (Mandatory=$false)] [string]$Proxy @@ -195,7 +193,7 @@ try { $argumentList += " /PID=`"$($productKey)`" " } - $argumentList + Start-Process -FilePath $setupPath -ArgumentList $argumentList write-host "==== Dismount the ISO file after installation ====" From 083232599d0cce05414f6415be51ecf0d2922177 Mon Sep 17 00:00:00 2001 From: "Alexander (Sasha) Nosov" Date: Tue, 9 Jul 2024 18:52:14 -0700 Subject: [PATCH 07/22] Added Az.Resources module --- .../install-payg-sql-server/install-payg-sql-server.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/install-payg-sql-server.ps1 b/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/install-payg-sql-server.ps1 index 769bfd4d..bd91c8ed 100644 --- a/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/install-payg-sql-server.ps1 +++ b/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/install-payg-sql-server.ps1 @@ -88,6 +88,7 @@ try { $requiredModules = @( "AzureAD", "Az.Accounts", + "Az.Resources", "Az.ConnectedMachine", "Az.ResourceGraph" ) From 6c61562967c765647e4f2f2aea97a5df8d07b1b6 Mon Sep 17 00:00:00 2001 From: "Alexander (Sasha) Nosov" Date: Tue, 9 Jul 2024 19:00:07 -0700 Subject: [PATCH 08/22] Fixed a typo --- .../install-payg-sql-server/install-payg-sql-server.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/install-payg-sql-server.ps1 b/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/install-payg-sql-server.ps1 index bd91c8ed..9373ae2e 100644 --- a/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/install-payg-sql-server.ps1 +++ b/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/install-payg-sql-server.ps1 @@ -145,7 +145,7 @@ try { # Pick the .iso file and mount - $noKeylist = "SQLFULL_ENU_ENTVL", "SQLFULL_ENU_STDVL", "SQLServer2022-x64-ENU-Ent", "SQLServer2022-x64-ENU-Std" + $noKeylist = "SQLFULL_ENU_ENTVL.iso", "SQLFULL_ENU_STDVL.iso", "SQLServer2022-x64-ENU-Ent.iso", "SQLServer2022-x64-ENU-Std.iso" foreach ($isoFile in $isoFiles) { $imagePath = $isoFile.FullName @@ -175,7 +175,7 @@ try { /INSTANCEDIR=C:\SQL /SQLSYSADMINACCOUNTS=`"$($SqlServerAdminAccounts)`" /SQLSVCACCOUNT=`"$($SqlServerSvcAccount)`" - /AGTSVCACCOUNT=`"$($SqlServerSvcAccount)`" + /AGTSVCACCOUNT=`"$($AgtServerSvcAccount)`" /IACCEPTSQLSERVERLICENSETERMS " if ($SqlServerSvcPassword) { From 814fbdee20277af02e534d0e8374238f4f5fcc37 Mon Sep 17 00:00:00 2001 From: "Alexander (Sasha) Nosov" Date: Mon, 29 Jul 2024 20:24:13 -0700 Subject: [PATCH 09/22] Update install-payg-sql-server.ps1 --- .../install-payg-sql-server/install-payg-sql-server.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/install-payg-sql-server.ps1 b/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/install-payg-sql-server.ps1 index 9373ae2e..b8d1bd16 100644 --- a/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/install-payg-sql-server.ps1 +++ b/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/install-payg-sql-server.ps1 @@ -217,7 +217,7 @@ try { $Settings = @{ SqlManagement = @{ IsEnabled = $true }; LicenseType = "PAYG"; - enableExtendedSecurityUpdates = $True; + enableExtendedSecurityUpdates = $False; esuLastUpdatedTimestamp = [DateTime]::UtcNow.ToString('yyyy-MM-ddTHH:mm:ss.fffZ') } New-AzConnectedMachineExtension -ResourceGroupName $AzureResourceGroup -MachineName $hostName -Name "Microsoft.AzureData" -Publisher "Microsoft.AzureData" -ExtensionType "WindowsAgent.SqlServer" -Location $AzureRegion -Settings $Settings -EnableAutomaticUpgrade From 1c452eed191ff9f318c45a17bfeb244e2cf14672 Mon Sep 17 00:00:00 2001 From: "Alexander (Sasha) Nosov" Date: Wed, 7 Aug 2024 18:17:18 -0700 Subject: [PATCH 10/22] Updated script and added readme --- .../install-payg-sql-server/README.md | 67 +++++++++++++++ .../install-payg-sql-server.ps1 | 83 +++++++++---------- 2 files changed, 107 insertions(+), 43 deletions(-) create mode 100644 samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/README.md diff --git a/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/README.md b/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/README.md new file mode 100644 index 00000000..e474aa4e --- /dev/null +++ b/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/README.md @@ -0,0 +1,67 @@ +# Overview + +This script installs a pay-as-you-go SQL Server instance on your machine and automatically connext it to Azure Arc using a downloaded SQL Server media. + +# Prerequisites + +- You have met the [onboarding prerequisites](https://learn.microsoft.com/sql/sql-server/azure-arc/prerequisites). +- You have downloded a SQL Server image file from the workspace provided by Microsoft technical support. Tpo obtain it, open a support request using "Get SQL Installation Media" subcategory and soecify the desired version and edition. +- You are a local admin on the machine where you run the script. +- Your n +- If you are using a machine running Windows Server 2016, you have completed the mitigation steps as described below. + + +# Mitigating the TLS version issue on Windows Server 2016 + +When running the script on Windows Server 2016, the OS may be configured with a TLS version that does not meet the Azure security requirements. You need to enable strong TLS versions (TLS 1.2 and 1.3) when they are available, while still supporting older TLS versions (1.0 and 1.1) when TLS 1.2 and 1.3 are unavailable. You need to also disable versions SSL2 and SSL3, which are insecure. + +To see if you need to make the change, run the command below from an elevated PowerShell prompt. +```PowerShell +[Net.ServicePointManager]::SecurityProtocol +``` + +If the result is `SSL3, Tls`, you need to fix the TLS version using one of the following options. + +__Option 1__: run the following command below from an elevated PowerShell prompt: +```PowerShell +[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls, [Net.SecurityProtocolType]::Tls11, [Net.SecurityProtocolType]::Tls12, [Net.SecurityProtocolType]::Tls13 +``` + +__Option 2__: run these two commands from an elevated PowerShell prompt: + +```PowerShell +Set-ItemProperty -Path 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\.NetFramework\v4.0.30319' -Name 'SchUseStrongCrypto' -Value '1' -Type DWord +Set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\.NetFramework\v4.0.30319' -Name 'SchUseStrongCrypto' -Value '1' -Type DWord +``` + +After running either of these command options, close and reopen PowerShell or reboot the machine (in case currently-running applications were referencing previous values). To verify that the changes were applied correctly, run this command again: +```PowerShell +[Net.ServicePointManager]::SecurityProtocol +``` +The result should be `Tls, Tls11, Tls12, Tls13` + +# Launching the script + +The script must be launched from and elevated PowerShell prompt. It accepts the following command line parameters: + +| **Parameter**                                         | **Value**                                                                       | **Description** | +|:--|:--|:--| +|-AzureSubscriptionId|subscription_id|Required: Subscription id that will contain the Arc-enabled machime and Arc-enable SQL Server resources. That subscription will be billed for SQL Server software using a pay-as-you-go method. | +|-AzureResourceGroup |resource_group_name|Required: Resource group that will contain the Arc-enabled machime and Arc-enable SQL Server resource.| +|-AzureRegion |region name| Required: the region to store the machuine and SQL Server meta-data. | +|-SqlServerInstanceName | name of the instance|Optional: the machine name will be used if not specified| +|-SqlServerAdminAccounts | SQL Server admin accounts | Optional. By default "BUILTIN\ADMINISTRATORS" will be used.| +|-SqlServerSvcAccount| SQL Server services account |Optional. By default "NT AUTHORITY\SYSTEM" will be used.| +|-SqlServerSvcPassword| SQL Server service account password| Required if a custom service account is specified.| +|-AgtServerSvcAccount|SQL Agent service account|Optional. By default "NT AUTHORITY\NETWORK SERVICE" will be used.| +|-AgtServerSvcPassword|SQL Agent service account pasdsword|Required if a custom service account is specified.| +|-IsoFolder|Folder path|Required. The folder contrainng the files downloaded from the workspace.| +|-Proxy|HTTP proxy URL|Optional. Needed if your networks is using a HTTP proxy.| + +## Example + +The following command installs a SQL Server instance from the folder `c:\downloads`, connect it to subscription ID ``, resource group `` in West US, and configure it with LicenseType=PAYG. It use the default admin and service accounts and direct connectivity to Azure. + +```PowerShell +.\install-payg-sql-server.ps1 -AzureSubscriptionId -AzureResourceGroup -AzureRegion westus -IsoFolder c:\downloads +``` diff --git a/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/install-payg-sql-server.ps1 b/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/install-payg-sql-server.ps1 index b8d1bd16..4f1d544b 100644 --- a/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/install-payg-sql-server.ps1 +++ b/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/install-payg-sql-server.ps1 @@ -15,6 +15,8 @@ param ( [string]$SqlServerSvcPassword, [Parameter (Mandatory=$false)] [string]$AgtServerSvcAccount = "NT AUTHORITY\NETWORK SERVICE", + [Parameter (Mandatory=$false)] + [string]$AgtServerSvcPassword, [Parameter (Mandatory=$true)] [string]$IsoFolder, [Parameter (Mandatory=$false)] @@ -76,9 +78,8 @@ function LoadModule } try { - + write-host "==== Ensure PS version and load missing Azure modules ====" - # # Suppress warnings # @@ -103,6 +104,7 @@ try { write-host "==== Log in to Azure ====" + Update-AzConfig -EnableLoginByWam $false Connect-AzAccount | Out-Null $subscription = Get-AzSubscription -SubscriptionId $AzureSubscriptionId -ErrorAction SilentlyContinue if (-not $subscription) { @@ -127,31 +129,34 @@ try { # Retrieve the product key if any - $keyFiles = Get-ChildItem $IsoFolder -Filter "*.txt" - + $keyFiles = (Get-ChildItem $IsoFolder -Filter "*.txt") + $productKey = "" foreach ($keyFile in $keyFiles) { # Read each line from the file - Get-Content $keyFile | ForEach-Object { - if ($_ -match "(?i)$($SqlServerEdition)" -and $_ -match "[A-Z0-9]{5,}-[A-Z0-9]{5,}-[A-Z0-9]{5,}-[A-Z0-9]{5,}-[A-Z0-9]{5,}.*") { + Get-Content $keyFile.fullname | ForEach-Object { + if ($_ -match "[A-Z0-9]{5,}-[A-Z0-9]{5,}-[A-Z0-9]{5,}-[A-Z0-9]{5,}-[A-Z0-9]{4,}.*") { # Extract the product key (including any following string after a space) - $productKey = [regex]::Match($_, '[A-Z0-9]{5,}-[A-Z0-9]{5,}-[A-Z0-9]{5,}-[A-Z0-9]{5,}-[A-Z0-9]{5,}.*').Value + $productKey = [regex]::Match($_, '[A-Z0-9]{5,}-[A-Z0-9]{5,}-[A-Z0-9]{5,}-[A-Z0-9]{5,}-[A-Z0-9]{4,}.*').Value # Strip any text after the product key $productKey = $productKey -replace " .*$" } } } - - $isoFiles = Get-ChildItem $IsoFolder -Filter "*.iso" + + $isoFiles = (Get-ChildItem $IsoFolder -Filter "*.iso") + + # Pick the .iso file and mount $noKeylist = "SQLFULL_ENU_ENTVL.iso", "SQLFULL_ENU_STDVL.iso", "SQLServer2022-x64-ENU-Ent.iso", "SQLServer2022-x64-ENU-Std.iso" foreach ($isoFile in $isoFiles) { + write-host("****isoFile: $($isoFile)") $imagePath = $isoFile.FullName if ($noKeylist -contains $isoFile.Name) {$productKey = ""} if (!(Get-DiskImage -ImagePath $imagePath).Attached) { - $mountResult = Mount-DiskImage -ImagePath $imagePath + $mountResult = Mount-DiskImage -ImagePath $imagePath -PassThru } else { $mountResult = Get-DiskImage -ImagePath $imagePath } @@ -164,40 +169,31 @@ try { write-host "==== Run unattended SQL Server setup from the mounted volume ====" - # Launch setup $setupPath = ($driveLetter + ":\setup.exe") - $argumentList = " - /q - /ACTION=`"Install`" - /FEATURES=SQL - /INSTANCEDIR=C:\SQL - /SQLSYSADMINACCOUNTS=`"$($SqlServerAdminAccounts)`" - /SQLSVCACCOUNT=`"$($SqlServerSvcAccount)`" - /AGTSVCACCOUNT=`"$($AgtServerSvcAccount)`" - /IACCEPTSQLSERVERLICENSETERMS - " - if ($SqlServerSvcPassword) { - $argumentList += " /SQLSVCPASSWORD=`"$($SqlServerSvcPassword)`" - " - } - if ($AgtServerSvcPassword) { - $argumentList += " /SQLAGTPASSWORD=`"$($AgtServerSvcPassword)`" - " - } - if ($SqlServerInstanceName) { - $argumentList += " /INSTANCENAME=`"$($SqlServerInstanceName) `" - " - } - if ($productKey) { - $argumentList += " /PID=`"$($productKey)`" - " - } + - Start-Process -FilePath $setupPath -ArgumentList $argumentList + $argumentList = "/q /ACTION=Install /FEATURES=SQL /SQLSVCACCOUNT=`"$($SqlServerSvcAccount)`" /SQLSYSADMINACCOUNTS=`"$($SqlServerAdminAccounts)`" /AGTSVCACCOUNT=`"$($AgtServerSvcAccount)`" /IACCEPTSQLSERVERLICENSETERMS" + # some optional arguments + if ($SqlServerInstanceName) { + $argumentList += " /INSTANCENAME= $($SqlServerInstanceName)" + } + if ($productKey) { + $argumentList += " /PID=`"$($productKey)`"" + } - write-host "==== Dismount the ISO file after installation ====" + if ($SqlServerSvcPassword) { + $argumentList += " /SQLSVCPASSWORD=`"$($SqlServerSvcPassword)`"" + } + + if ($AgtSvCPassword) { + $argumentList += " /AGTSVCPASSWORD=`"$($AgtSvCPassword)`"" + } + + + Start-Process -Wait -FilePath $setupPath -ArgumentList $argumentList -RedirectStandardOutput setup-output.txt + Dismount-DiskImage -ImagePath $imagePath | Out-Null @@ -213,16 +209,17 @@ try { write-host "==== Install SQL Arc extension with LT=PAYG and upgrade to the latest version ====" - $extensionName = "WindowsAgent.SqlServer" + $Settings = @{ SqlManagement = @{ IsEnabled = $true }; LicenseType = "PAYG"; enableExtendedSecurityUpdates = $False; - esuLastUpdatedTimestamp = [DateTime]::UtcNow.ToString('yyyy-MM-ddTHH:mm:ss.fffZ') } - New-AzConnectedMachineExtension -ResourceGroupName $AzureResourceGroup -MachineName $hostName -Name "Microsoft.AzureData" -Publisher "Microsoft.AzureData" -ExtensionType "WindowsAgent.SqlServer" -Location $AzureRegion -Settings $Settings -EnableAutomaticUpgrade - # Step 10: Display the status of the Azure resource for Arc-enabled SQL Server + + New-AzConnectedMachineExtension -ResourceGroupName $AzureResourceGroup -MachineName $hostName -Name "WindowsAgent.SqlServer" -Publisher "Microsoft.AzureData" -ExtensionType "WindowsAgent.SqlServer" -Location $AzureRegion -Settings $Settings -EnableAutomaticUpgrade + + write-host "==== Display the status of the billable Arc-enabled host ====" $query = " From f901d45077b57239b0861c0f3c517ae2e60e8b78 Mon Sep 17 00:00:00 2001 From: "Alexander (Sasha) Nosov" Date: Wed, 7 Aug 2024 18:21:18 -0700 Subject: [PATCH 11/22] Minor edits --- .../install-payg-sql-server/README.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/README.md b/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/README.md index e474aa4e..d7a48266 100644 --- a/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/README.md +++ b/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/README.md @@ -1,14 +1,13 @@ # Overview -This script installs a pay-as-you-go SQL Server instance on your machine and automatically connext it to Azure Arc using a downloaded SQL Server media. +This script installs a pay-as-you-go SQL Server instance on your machine and automatically connects it to Azure using a downloaded SQL Server media. # Prerequisites - You have met the [onboarding prerequisites](https://learn.microsoft.com/sql/sql-server/azure-arc/prerequisites). -- You have downloded a SQL Server image file from the workspace provided by Microsoft technical support. Tpo obtain it, open a support request using "Get SQL Installation Media" subcategory and soecify the desired version and edition. +- You have downloded a SQL Server image file from the workspace provided by Microsoft technical support. To obtain it, open a support request using "Get SQL Installation Media" subcategory and specify the desired version and edition. - You are a local admin on the machine where you run the script. -- Your n -- If you are using a machine running Windows Server 2016, you have completed the mitigation steps as described below. +- If you are installing SQL Server on Windows Server 2016, you have a secure TLS configuration as described below. # Mitigating the TLS version issue on Windows Server 2016 From 624e84a759c5ed55d3c4f2fecd9812d8f74fafc7 Mon Sep 17 00:00:00 2001 From: "Alexander (Sasha) Nosov" Date: Wed, 7 Aug 2024 18:32:27 -0700 Subject: [PATCH 12/22] Added curl --- .../install-payg-sql-server/README.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/README.md b/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/README.md index d7a48266..58b13ed9 100644 --- a/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/README.md +++ b/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/README.md @@ -39,9 +39,17 @@ After running either of these command options, close and reopen PowerShell or re ``` The result should be `Tls, Tls11, Tls12, Tls13` +# Downloading the script + +To download the script to your current folder run: + + ```console + curl https://raw.githubusercontent.com/microsoft/sql-server-samples/master/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/install-payg-sql-server.ps1 -o install-payg-sql-server.ps1 + ``` + # Launching the script -The script must be launched from and elevated PowerShell prompt. It accepts the following command line parameters: +The script must be run in an elevated PowerShell session. It accepts the following command line parameters: | **Parameter**                                         | **Value**                                                                       | **Description** | |:--|:--|:--| From 0f55a71131f02293a506b69dece86ae012c12a75 Mon Sep 17 00:00:00 2001 From: "Alexander (Sasha) Nosov" Date: Wed, 7 Aug 2024 18:36:24 -0700 Subject: [PATCH 13/22] Update README.md --- .../install-payg-sql-server/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/README.md b/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/README.md index 58b13ed9..a33be9d2 100644 --- a/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/README.md +++ b/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/README.md @@ -6,7 +6,7 @@ This script installs a pay-as-you-go SQL Server instance on your machine and aut - You have met the [onboarding prerequisites](https://learn.microsoft.com/sql/sql-server/azure-arc/prerequisites). - You have downloded a SQL Server image file from the workspace provided by Microsoft technical support. To obtain it, open a support request using "Get SQL Installation Media" subcategory and specify the desired version and edition. -- You are a local admin on the machine where you run the script. +- You are logged in to the machine with a administrator account. - If you are installing SQL Server on Windows Server 2016, you have a secure TLS configuration as described below. From 83b383409b12355a6cfb2fdb02351e2b7065cec1 Mon Sep 17 00:00:00 2001 From: "Alexander (Sasha) Nosov" Date: Wed, 7 Aug 2024 18:37:43 -0700 Subject: [PATCH 14/22] Update README.md --- .../install-payg-sql-server/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/README.md b/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/README.md index a33be9d2..b20d3797 100644 --- a/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/README.md +++ b/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/README.md @@ -63,7 +63,7 @@ The script must be run in an elevated PowerShell session. It accepts the followi |-AgtServerSvcAccount|SQL Agent service account|Optional. By default "NT AUTHORITY\NETWORK SERVICE" will be used.| |-AgtServerSvcPassword|SQL Agent service account pasdsword|Required if a custom service account is specified.| |-IsoFolder|Folder path|Required. The folder contrainng the files downloaded from the workspace.| -|-Proxy|HTTP proxy URL|Optional. Needed if your networks is using a HTTP proxy.| +|-Proxy|HTTP proxy URL|Optional. Needed if your networks is configured with an HTTP proxy.| ## Example From 1984db06617e245cc898ff733a09984dce428c6d Mon Sep 17 00:00:00 2001 From: "Alexander (Sasha) Nosov" Date: Wed, 7 Aug 2024 18:38:16 -0700 Subject: [PATCH 15/22] Update README.md --- .../install-payg-sql-server/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/README.md b/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/README.md index b20d3797..f072322f 100644 --- a/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/README.md +++ b/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/README.md @@ -65,7 +65,7 @@ The script must be run in an elevated PowerShell session. It accepts the followi |-IsoFolder|Folder path|Required. The folder contrainng the files downloaded from the workspace.| |-Proxy|HTTP proxy URL|Optional. Needed if your networks is configured with an HTTP proxy.| -## Example +# Example The following command installs a SQL Server instance from the folder `c:\downloads`, connect it to subscription ID ``, resource group `` in West US, and configure it with LicenseType=PAYG. It use the default admin and service accounts and direct connectivity to Azure. From 8e2f6ae8205d45881d6898d85a110579637aead4 Mon Sep 17 00:00:00 2001 From: "Alexander (Sasha) Nosov" Date: Thu, 8 Aug 2024 10:40:37 -0700 Subject: [PATCH 16/22] Update README.md --- .../install-payg-sql-server/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/README.md b/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/README.md index f072322f..53f56d98 100644 --- a/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/README.md +++ b/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/README.md @@ -6,7 +6,7 @@ This script installs a pay-as-you-go SQL Server instance on your machine and aut - You have met the [onboarding prerequisites](https://learn.microsoft.com/sql/sql-server/azure-arc/prerequisites). - You have downloded a SQL Server image file from the workspace provided by Microsoft technical support. To obtain it, open a support request using "Get SQL Installation Media" subcategory and specify the desired version and edition. -- You are logged in to the machine with a administrator account. +- You are logged in to the machine with an administrator account. - If you are installing SQL Server on Windows Server 2016, you have a secure TLS configuration as described below. @@ -67,7 +67,7 @@ The script must be run in an elevated PowerShell session. It accepts the followi # Example -The following command installs a SQL Server instance from the folder `c:\downloads`, connect it to subscription ID ``, resource group `` in West US, and configure it with LicenseType=PAYG. It use the default admin and service accounts and direct connectivity to Azure. +The following command installs a SQL Server instance from the folder `c:\downloads`, connects it to subscription ID ``, resource group `` in the West US region, and configures it with LicenseType=PAYG. It uses the default admin and service accounts, and uses a direct connection to Azure. ```PowerShell .\install-payg-sql-server.ps1 -AzureSubscriptionId -AzureResourceGroup -AzureRegion westus -IsoFolder c:\downloads From 4849fcc911f1d53541863d4b9034b996efbec5d0 Mon Sep 17 00:00:00 2001 From: "Alexander (Sasha) Nosov" Date: Tue, 13 Aug 2024 10:46:08 -0700 Subject: [PATCH 17/22] Fixed typos --- .../install-payg-sql-server/README.md | 22 +++++++------------ 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/README.md b/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/README.md index 53f56d98..771490b0 100644 --- a/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/README.md +++ b/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/README.md @@ -5,7 +5,7 @@ This script installs a pay-as-you-go SQL Server instance on your machine and aut # Prerequisites - You have met the [onboarding prerequisites](https://learn.microsoft.com/sql/sql-server/azure-arc/prerequisites). -- You have downloded a SQL Server image file from the workspace provided by Microsoft technical support. To obtain it, open a support request using "Get SQL Installation Media" subcategory and specify the desired version and edition. +- You have downloaded a SQL Server image file from the workspace provided by Microsoft technical support. To obtain it, open a support request using "Get SQL Installation Media" subcategory and specify the desired version and edition. - You are logged in to the machine with an administrator account. - If you are installing SQL Server on Windows Server 2016, you have a secure TLS configuration as described below. @@ -19,21 +19,15 @@ To see if you need to make the change, run the command below from an elevated Po [Net.ServicePointManager]::SecurityProtocol ``` -If the result is `SSL3, Tls`, you need to fix the TLS version using one of the following options. - -__Option 1__: run the following command below from an elevated PowerShell prompt: -```PowerShell -[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls, [Net.SecurityProtocolType]::Tls11, [Net.SecurityProtocolType]::Tls12, [Net.SecurityProtocolType]::Tls13 -``` - -__Option 2__: run these two commands from an elevated PowerShell prompt: +If the result is `SSL3, Tls`, you need to fix the TLS version by running the following commands. ```PowerShell Set-ItemProperty -Path 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\.NetFramework\v4.0.30319' -Name 'SchUseStrongCrypto' -Value '1' -Type DWord Set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\.NetFramework\v4.0.30319' -Name 'SchUseStrongCrypto' -Value '1' -Type DWord ``` -After running either of these command options, close and reopen PowerShell or reboot the machine (in case currently-running applications were referencing previous values). To verify that the changes were applied correctly, run this command again: +After running these commands, reboot the machine (in case currently-running applications were referencing previous values). To verify that the changes were applied correctly, run this command again: + ```PowerShell [Net.ServicePointManager]::SecurityProtocol ``` @@ -53,16 +47,16 @@ The script must be run in an elevated PowerShell session. It accepts the followi | **Parameter**                                         | **Value**                                                                       | **Description** | |:--|:--|:--| -|-AzureSubscriptionId|subscription_id|Required: Subscription id that will contain the Arc-enabled machime and Arc-enable SQL Server resources. That subscription will be billed for SQL Server software using a pay-as-you-go method. | -|-AzureResourceGroup |resource_group_name|Required: Resource group that will contain the Arc-enabled machime and Arc-enable SQL Server resource.| +|-AzureSubscriptionId|subscription_id|Required: Subscription id that will contain the Arc-enabled machine and Arc-enable SQL Server resources. That subscription will be billed for SQL Server software using a pay-as-you-go method. | +|-AzureResourceGroup |resource_group_name|Required: Resource group that will contain the Arc-enabled machine and Arc-enable SQL Server resource.| |-AzureRegion |region name| Required: the region to store the machuine and SQL Server meta-data. | |-SqlServerInstanceName | name of the instance|Optional: the machine name will be used if not specified| |-SqlServerAdminAccounts | SQL Server admin accounts | Optional. By default "BUILTIN\ADMINISTRATORS" will be used.| |-SqlServerSvcAccount| SQL Server services account |Optional. By default "NT AUTHORITY\SYSTEM" will be used.| |-SqlServerSvcPassword| SQL Server service account password| Required if a custom service account is specified.| |-AgtServerSvcAccount|SQL Agent service account|Optional. By default "NT AUTHORITY\NETWORK SERVICE" will be used.| -|-AgtServerSvcPassword|SQL Agent service account pasdsword|Required if a custom service account is specified.| -|-IsoFolder|Folder path|Required. The folder contrainng the files downloaded from the workspace.| +|-AgtServerSvcPassword|SQL Agent service account password|Required if a custom service account is specified.| +|-IsoFolder|Folder path|Required. The folder containing the files downloaded from the workspace.| |-Proxy|HTTP proxy URL|Optional. Needed if your networks is configured with an HTTP proxy.| # Example From f17e36fdfe37dcd1a13ddb844a00971c502b355a Mon Sep 17 00:00:00 2001 From: "Alexander (Sasha) Nosov" Date: Tue, 13 Aug 2024 10:49:35 -0700 Subject: [PATCH 18/22] Fixed curl command --- .../install-payg-sql-server/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/README.md b/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/README.md index 771490b0..59a15e20 100644 --- a/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/README.md +++ b/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/README.md @@ -37,7 +37,7 @@ The result should be `Tls, Tls11, Tls12, Tls13` To download the script to your current folder run: - ```console + ```PowerShell curl https://raw.githubusercontent.com/microsoft/sql-server-samples/master/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/install-payg-sql-server.ps1 -o install-payg-sql-server.ps1 ``` From 58d176fb224f0e9a91e00305652dbf2ecab84285 Mon Sep 17 00:00:00 2001 From: "Alexander (Sasha) Nosov" Date: Tue, 13 Aug 2024 10:50:40 -0700 Subject: [PATCH 19/22] Fixed concole command --- .../install-payg-sql-server/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/README.md b/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/README.md index 59a15e20..86cd0cdf 100644 --- a/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/README.md +++ b/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/README.md @@ -37,9 +37,9 @@ The result should be `Tls, Tls11, Tls12, Tls13` To download the script to your current folder run: - ```PowerShell - curl https://raw.githubusercontent.com/microsoft/sql-server-samples/master/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/install-payg-sql-server.ps1 -o install-payg-sql-server.ps1 - ``` +```console +curl https://raw.githubusercontent.com/microsoft/sql-server-samples/master/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/install-payg-sql-server.ps1 -o install-payg-sql-server.ps1 +``` # Launching the script From e125b27e275cf29b2478e53009be0440bd87802d Mon Sep 17 00:00:00 2001 From: "Alexander (Sasha) Nosov" Date: Tue, 13 Aug 2024 10:52:33 -0700 Subject: [PATCH 20/22] Fixed services default --- .../install-payg-sql-server/README.md | 2 +- .../install-payg-sql-server/install-payg-sql-server.ps1 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/README.md b/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/README.md index 86cd0cdf..14833268 100644 --- a/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/README.md +++ b/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/README.md @@ -52,7 +52,7 @@ The script must be run in an elevated PowerShell session. It accepts the followi |-AzureRegion |region name| Required: the region to store the machuine and SQL Server meta-data. | |-SqlServerInstanceName | name of the instance|Optional: the machine name will be used if not specified| |-SqlServerAdminAccounts | SQL Server admin accounts | Optional. By default "BUILTIN\ADMINISTRATORS" will be used.| -|-SqlServerSvcAccount| SQL Server services account |Optional. By default "NT AUTHORITY\SYSTEM" will be used.| +|-SqlServerSvcAccount| SQL Server services account |Optional. By default "NT AUTHORITY\NETWORK SERVICE" will be used.| |-SqlServerSvcPassword| SQL Server service account password| Required if a custom service account is specified.| |-AgtServerSvcAccount|SQL Agent service account|Optional. By default "NT AUTHORITY\NETWORK SERVICE" will be used.| |-AgtServerSvcPassword|SQL Agent service account password|Required if a custom service account is specified.| diff --git a/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/install-payg-sql-server.ps1 b/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/install-payg-sql-server.ps1 index 4f1d544b..0a4efb63 100644 --- a/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/install-payg-sql-server.ps1 +++ b/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/install-payg-sql-server.ps1 @@ -10,7 +10,7 @@ param ( [Parameter (Mandatory=$false)] [string]$SqlServerAdminAccounts = "BUILTIN\ADMINISTRATORS", [Parameter (Mandatory=$false)] - [string]$SqlServerSvcAccount = "NT AUTHORITY\SYSTEM", + [string]$SqlServerSvcAccount = "NT AUTHORITY\NETWORK SERVICE", [Parameter (Mandatory=$false)] [string]$SqlServerSvcPassword, [Parameter (Mandatory=$false)] From a6de85e07e80312089a053bb46b71ea3003b54cc Mon Sep 17 00:00:00 2001 From: "Alexander (Sasha) Nosov" Date: Tue, 13 Aug 2024 14:26:14 -0700 Subject: [PATCH 21/22] Fixed download folder --- .../install-payg-sql-server/README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/README.md b/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/README.md index 14833268..94164dff 100644 --- a/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/README.md +++ b/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/README.md @@ -5,7 +5,7 @@ This script installs a pay-as-you-go SQL Server instance on your machine and aut # Prerequisites - You have met the [onboarding prerequisites](https://learn.microsoft.com/sql/sql-server/azure-arc/prerequisites). -- You have downloaded a SQL Server image file from the workspace provided by Microsoft technical support. To obtain it, open a support request using "Get SQL Installation Media" subcategory and specify the desired version and edition. +- You have downloaded a SQL Server image file from the workspace provided by Microsoft technical support. To obtain it, open a support request using the "Get SQL Installation Media" subcategory and specify the desired version and edition. - You are logged in to the machine with an administrator account. - If you are installing SQL Server on Windows Server 2016, you have a secure TLS configuration as described below. @@ -61,8 +61,9 @@ The script must be run in an elevated PowerShell session. It accepts the followi # Example -The following command installs a SQL Server instance from the folder `c:\downloads`, connects it to subscription ID ``, resource group `` in the West US region, and configures it with LicenseType=PAYG. It uses the default admin and service accounts, and uses a direct connection to Azure. +The following command installs a SQL Server instance from the download folder, connects it to subscription ID ``, resource group `` in the West US region, and configures it with LicenseType=PAYG. It uses the default admin and service accounts, and uses a direct connection to Azure. ```PowerShell -.\install-payg-sql-server.ps1 -AzureSubscriptionId -AzureResourceGroup -AzureRegion westus -IsoFolder c:\downloads +.\install-payg-sql-server.ps1 -AzureSubscriptionId -AzureResourceGroup -AzureRegion westus -IsoFolder C:\Users\[YourUsername]\Downloads + ``` From 9c82e6ef31efaa54aeaa8f37ece8b9efceb6b0b5 Mon Sep 17 00:00:00 2001 From: "Alexander (Sasha) Nosov" Date: Tue, 13 Aug 2024 14:28:58 -0700 Subject: [PATCH 22/22] Update README.md --- .../install-payg-sql-server/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/README.md b/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/README.md index 94164dff..fd67a5b8 100644 --- a/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/README.md +++ b/samples/manage/azure-arc-enabled-sql-server/install-payg-sql-server/README.md @@ -61,7 +61,7 @@ The script must be run in an elevated PowerShell session. It accepts the followi # Example -The following command installs a SQL Server instance from the download folder, connects it to subscription ID ``, resource group `` in the West US region, and configures it with LicenseType=PAYG. It uses the default admin and service accounts, and uses a direct connection to Azure. +The following command installs a SQL Server instance from the Downloads folder, connects it to subscription ID ``, resource group `` in the West US region, and configures it with LicenseType=PAYG. It uses the default admin and service accounts, and uses a direct connection to Azure. ```PowerShell .\install-payg-sql-server.ps1 -AzureSubscriptionId -AzureResourceGroup -AzureRegion westus -IsoFolder C:\Users\[YourUsername]\Downloads