更新 SQL 資源提供者

重要

從 Azure Stack Hub 組建 2108 開始,提供 SQL 和 MySQL 資源提供者授與存取權的訂用帳戶。 若要開始使用這項功能,或需要從舊版升級,請開啟支援案例,我們的支援工程師會引導您完成部署或升級程序。

重要

在更新資源提供者之前,請先檢閱版本資訊,以了解有哪些新功能、修正,以及任何可能對部署造成影響的已知問題。 版本資訊也會指定資源提供者所需的最低 Azure Stack Hub 版本。

重要

更新資源提供者不會更新主機 SQL Server。

當 Azure Stack Hub 更新為新的組建時,可能會發行新的 SQL 資源提供者。 雖然現有資源提供者仍可正常運作,但建議您盡快更新至最新組建。

支援的 Azure Stack Hub 版本 SQL RP 版本 執行 RP 服務的 Windows Server
2206, 2301, 2306 SQL RP 2.0.13.x 版 MicMicrosoft AzureStack 附加元件 RP Windows Server 1.2009.0
2108, 2206 SQL RP 2.0.6.x 版 MicMicrosoft AzureStack 附加元件 RP Windows Server 1.2009.0

更新 SQL Server 資源提供者 V2

如果您已部署 SQL RP V2,並想要檢查更新,請參閱如何套用更新至資源提供者

如果您想要從 SQL RP V1 更新至 SQL RP V2,請確定您必須先更新為 SQL RP V1.1.93.x,然後套用主要版本升級程式,以從 SQL RP V1 升級至 SQL RP V2。

從 SQL RP V1.1.93.x 更新至 SQL RP V2.0.6.0

必要條件

  1. 請確定 SQL RP V1 已更新至最新的 1.1.93.x。 在 [預設提供者訂用帳戶] 下,尋找 [RP 資源群組 (命名格式:system.<region>.sqladapter)]。 確認版本標籤和資源群組的 SQL RP VM 名稱。 如果您仍在舊版,且需要更新為 1.1.93.x,請開啟支援案例以取得協助。

  2. 開啟支援案例取得 MajorVersionUpgrade 套件,並新增訂用帳戶至未來 V2 版本的 ASH 市集允許清單。

  3. 下載 Microsoft AzureStack 附加元件 RP Windows Server 1.2009.0 至市集。

  4. 請確定符合資料中心整合必要條件。

必要條件 參考
條件式 DNS 轉送已正確設定。 Azure Stack Hub 資料中心整合 - DNS
資源提供者的輸入連接埠已開啟。 Azure Stack Hub 資料中心整合 - 輸入連接埠和通訊協定
PKI 憑證主體和 SAN 已正確設定。 Azure Stack Hub 部署必要 PKI 必要條件
Azure Stack Hub 部署 PaaS 憑證必要條件
  1. (中斷連線的環境) 安裝必要的 PowerShell 模組,類似於用來 部署資源提供者的更新程式。

觸發 MajorVersionUpgrade

使用提高權限的 PowerShell 主控台,執行下列指令碼,並執行主要版本升級。

注意

請確定執行指令碼的用戶端電腦作業系統版本,是 Windows 10 或 Windows Server 2016 以後的版本,且用戶端電腦使用 X64 作業系統結構。

重要

執行部署或更新指令碼前,強烈建議您使用 Clear-AzureRmContext -Scope CurrentUserClear-AzureRmContext -Scope Process 清除快取。

# Check Operating System version
$osVersion = [environment]::OSVersion.Version
if ($osVersion.Build -lt 10240)
{
    Write-Host "OS version is too old: $osVersion."
    return
}

$osArch = (Get-WmiObject Win32_OperatingSystem).OSArchitecture
if ($osArch -ne "64-bit")
{
    Write-Host "OS Architecture is not 64 bit."
    return
}

# Check LongPathsEnabled registry key
$regPath = 'HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem'
$longPathsEnabled = 'LongPathsEnabled'
$property = Get-ItemProperty -Path $regPath -Name $longPathsEnabled -ErrorAction Stop
if ($property.LongPathsEnabled -eq 0)
{
    Write-Host "Detect LongPathsEnabled equals to 0, prepare to set the property."
    Set-ItemProperty -Path $regPath -Name $longPathsEnabled -Value 1 -ErrorAction Stop
    Write-Host "Set the long paths property, please restart the PowerShell."
    return
} 

# Use the NetBIOS name for the Azure Stack Hub domain. 
$domain = "YouDomain" 

# For integrated systems, use the IP address of one of the ERCS VMs
$privilegedEndpoint = "YouDomain-ERCS01"

# Provide the Azure environment used for deploying Azure Stack Hub. Required only for Azure AD deployments. Supported values for the <environment name> parameter are AzureCloud, AzureChinaCloud, or AzureUSGovernment depending which Azure subscription you're using.
$AzureEnvironment = "AzureCloud"

# Point to the directory where the resource provider installation files were extracted.
$tempDir = 'C:\extracted-folder\MajorVersionUpgrade-SQLRP'

# The service admin account can be Azure Active Directory or Active Directory Federation Services.
$serviceAdmin = "admin@mydomain.onmicrosoft.com"
$AdminPass = ConvertTo-SecureString 'xxxxxxxx' -AsPlainText -Force
$AdminCreds = New-Object System.Management.Automation.PSCredential ($serviceAdmin, $AdminPass)

# Add the cloudadmin credential that's required for privileged endpoint access.
$CloudAdminPass = ConvertTo-SecureString 'xxxxxxxx' -AsPlainText -Force
$CloudAdminCreds = New-Object System.Management.Automation.PSCredential ("$domain\cloudadmin", $CloudAdminPass)

# Change the following as appropriate.
$PfxPass = ConvertTo-SecureString 'xxxxxxx' -AsPlainText -Force

# Provide the pfx file path
$PfxFilePath = "C:\tools\sqlcert\SSL.pfx"

# PowerShell modules used by the RP MajorVersionUpgrade are placed in C:\Program Files\SqlMySqlPsh
# The deployment script adds this path to the system $env:PSModulePath to ensure correct modules are used.
$rpModulePath = Join-Path -Path $env:ProgramFiles -ChildPath 'SqlMySqlPsh'
$env:PSModulePath = $env:PSModulePath + ";" + $rpModulePath 

. $tempDir\MajorVersionUpgradeSQLProvider.ps1 -AzureEnvironment $AzureEnvironment -AzCredential $AdminCreds -CloudAdminCredential $CloudAdminCreds -Privilegedendpoint $privilegedEndpoint -PfxPassword $PfxPass -PfxCert $PfxFilePath

注意

DNS 位址與 SQL RP V2 對應的 IP 位址不同。 若要取得新的公用 IP,您可以聯絡支援人員,要求 DRP 中斷玻璃效果,並找出 SQLRPVM1130-PublicIP 資源。 您也可以使用已通過端點測試的用戶端電腦,執行「nslookup sqlrp.dbadapter.<fqdn>」找出公用 IP。

驗證升級成功

  1. 執行 MajorVersionUpgrade 指令碼時沒有任何錯誤。
  2. 請檢查市集的資源提供者,並確定已成功安裝 SQL RP 2.0。
  3. 指令碼不會自動刪除舊的 system.<location>.sqladapter 資源群組和預設提供者訂用帳戶的 system.<location>.dbadapter.dns 資源群組。
  • 建議您在 sqladapter 資源群組中保留記憶體帳戶和 金鑰保存庫 一段時間。 如果升級後,任何租用戶使用者觀察到不一致的資料庫或登入中繼資料,即可從資源群組取得還原中繼資料的支援。
  • 確認 dbadapter.dn 資源群組的 DNS 區域沒有 DNS 記錄後,即可放心刪除 dbadapter.dns 資源群組。
  • [重要] 請勿使用 V1 部署指令碼解除安裝 V1 版。 升級完成並確認升級成功後,您可以從提供者訂用帳戶手動刪除資源群組。

從 SQL RP V1 以前的版本更新至 SQL RP V1.1.93.x

SQL 資源提供者 V1 更新是累積更新。 您可以直接更新至 1.1.93.x 版本。

若要更新資源提供者至 1.1.93.x,請使用 UpdateSQLProvider.ps1 指令碼。 請使用具有本機系統管理權限、並且是訂用帳戶擁有者的服務帳戶。 此更新指令碼包含在資源提供者的下載中。

此更新程序類似於用來部署資源提供者的程序。 更新指令碼會使用和 DeploySqlProvider.ps1 指令碼相同的引數,而且您必須提供憑證資訊。

更新指令碼程序

UpdateSQLProvider.ps1 指令碼會建立包含最新 OS 映像的新虛擬機器 (VM)、部署最新的資源提供者程式碼,並遷移舊資源提供者的設定至新資源提供者。

注意

建議您從市集管理下載 Microsoft AzureStack 附加元件 RP Windows Server 1.2009.0 映像。 如果您需要安裝某個更新,可以將單一 MSU 套件放在本機相依性路徑中。 如果這個位置中有多個 MSU 檔案,指令碼就會失敗。

UpdateSQLProvider.ps1 指令碼建立新的 VM 後,指令碼會遷移下列的舊資源提供者 VM 設定:

  • 資料庫資訊
  • 裝載伺服器資訊
  • 必要的 DNS 記錄

重要

執行部署或更新指令碼前,強烈建議您使用 Clear-AzureRmContext -Scope CurrentUserClear-AzureRmContext -Scope 程序清除快取。

更新指令碼參數

您可以在執行 UpdateSQLProvider.ps1 PowerShell 指令碼時從命令列指定下列參數。 如果未指定參數,或任何參數驗證失敗,系統就會提示您提供所需的參數。

參數名稱 描述 註解或預設值
CloudAdminCredential 雲端管理員的認證,這是存取具特殊權限端點所需的認證。 必要
AzCredential Azure Stack Hub 服務管理帳戶的認證。 使用與部署 Azure Stack Hub 時所用認證相同的認證。 如果您搭配 AzCredential 使用的帳戶需要多重要素驗證, (MFA) ,腳本將會失敗。 必要
VMLocalCredential SQL 資源提供者 VM 之本機系統管理員帳戶的認證。 必要
PrivilegedEndpoint 具特殊權限端點的 IP 位址或 DNS 名稱。 必要
AzureEnvironment 您用來部署 Azure Stack Hub 的服務管理員帳戶所屬的 Azure 環境。 僅適用於 Microsoft Entra 部署。 支持的環境名稱為 AzureCloudAzureUSGovernment,或使用中國 Microsoft Entra 標識符 AzureChinaCloud AzureCloud
DependencyFilesLocalPath 您也必須將憑證 .pfx 檔案放在這個目錄中。 若為單一節點,屬選擇性,若為多重節點,則屬必要
DefaultSSLCertificatePassword .pfx 憑證的密碼。 必要
MaxRetryCount 當作業失敗時,您想要重試每個作業的次數。 2
RetryDuration 重試之間的逾時間隔 (秒)。 120
解除安裝 移除資源提供者及所有關聯的資源。
DebugMode 防止在失敗時自動清除。

更新指令碼 PowerShell 範例

如果您要更新 SQL 資源提供者至 1.1.33.0 版或之前的版本,請在 PowerShell 中安裝特定版本的 AzureRm.BootStrapper 和 Azure Stack Hub 模組。

如果您要更新 SQL 資源提供者至 1.1.47.0 版或更新版本,即可跳過此步驟。 部署指令碼會自動下載並安裝必要的 PowerShell 模組至路徑 C:\Program Files\SqlMySqlPsh。

注意

如果下載 PowerShell 模組後已有資料夾 C:\Program Files\SqlMySqlPsh,建議您在執行更新指令碼前清除此資料夾。 這是為了確保下載和使用的 PowerShell 模組是正確版本。

# Run the following scripts when updating to version 1.1.33.0 only.
# Install the AzureRM.Bootstrapper module, set the profile, and install the AzureStack module.
# Note that this might not be the most currently available version of Azure Stack Hub PowerShell.
Install-Module -Name AzureRm.BootStrapper -Force
Use-AzureRmProfile -Profile 2018-03-01-hybrid -Force
Install-Module -Name AzureStack -RequiredVersion 1.6.0

注意

在中斷連線的情況下,您必須下載必要的 PowerShell 模組,並手動註冊存放庫,因為這是必要條件。 您可以在部署 SQL 資源提供者中取得詳細資訊

以下舉例說明如何使用可從已提升權限的 PowerShell 主控台來執行的 UpdateSQLProvider.ps1 指令碼。 請務必視需要變更變數資訊和密碼:

# Use the NetBIOS name for the Azure Stack Hub domain. On the Azure Stack Hub SDK, the default is AzureStack but this might have been changed at installation.
$domain = "AzureStack"

# For integrated systems, use the IP address of one of the ERCS VMs.
$privilegedEndpoint = "AzS-ERCS01"

# Provide the Azure environment used for deploying Azure Stack Hub. Required only for Azure AD deployments. Supported values for the <environment name> parameter are AzureCloud, AzureChinaCloud, or AzureUSGovernment depending which Azure subscription you're using.
$AzureEnvironment = "<EnvironmentName>"

# Point to the directory where the resource provider installation files were extracted.
$tempDir = 'C:\TEMP\SQLRP'

# The service admin account (this can be Azure AD or AD FS).
$serviceAdmin = "admin@mydomain.onmicrosoft.com"
$AdminPass = ConvertTo-SecureString 'P@ssw0rd1' -AsPlainText -Force
$AdminCreds = New-Object System.Management.Automation.PSCredential ($serviceAdmin, $AdminPass)

# Set the credentials for the new resource provider VM.
$vmLocalAdminPass = ConvertTo-SecureString 'P@ssw0rd1' -AsPlainText -Force
$vmLocalAdminCreds = New-Object System.Management.Automation.PSCredential ("sqlrpadmin", $vmLocalAdminPass)

# Add the cloudadmin credential required for privileged endpoint access.
$CloudAdminPass = ConvertTo-SecureString 'P@ssw0rd1' -AsPlainText -Force
$CloudAdminCreds = New-Object System.Management.Automation.PSCredential ("$domain\cloudadmin", $CloudAdminPass)

# Change the following as appropriate.
$PfxPass = ConvertTo-SecureString 'P@ssw0rd1' -AsPlainText -Force

# For version 1.1.47.0 or later, the PowerShell modules used by the RP deployment are placed in C:\Program Files\SqlMySqlPsh
# The deployment script adds this path to the system $env:PSModulePath to ensure correct modules are used.
$rpModulePath = Join-Path -Path $env:ProgramFiles -ChildPath 'SqlMySqlPsh'
$env:PSModulePath = $env:PSModulePath + ";" + $rpModulePath

# Change directory to the folder where you extracted the installation files.
# Then adjust the endpoints.
. $tempDir\UpdateSQLProvider.ps1 -AzCredential $AdminCreds -VMLocalCredential $vmLocalAdminCreds -CloudAdminCredential $cloudAdminCreds -PrivilegedEndpoint $privilegedEndpoint -AzureEnvironment $AzureEnvironment -DefaultSSLCertificatePassword $PfxPass -DependencyFilesLocalPath $tempDir\cert

當資源提供者更新指令碼完成時,請關閉目前的 PowerShell 工作階段。

後續步驟

維護 SQL 資源提供者