subscription="00000000-0000-0000-0000-000000000000" # Replace with your subscription ID
resourceGroup="hcicluster-rg" # Replace with your resource group name
az account set --subscription "${subscription}"
clusters=($(az graph query -q "resources | where type == 'microsoft.azurestackhci/clusters'| where resourceGroup =~ '${resourceGroup}' | project name" | jq -r '.data[].name'))
若要在資源群組下的所有系統上安裝 Windows Admin Center 擴充功能,請執行下列命令:
extensionName="AdminCenter"
extensionType="AdminCenter"
extensionPublisher="Microsoft.AdminCenter"
settingsConfig="{'port':'6516'}"
connectivityProps="{enabled:true}"
for cluster in ${clusters}; do
echo "Enabling Connectivity for cluster $currentCluster"
az stack-hci arc-setting update \
--resource-group ${resourceGroup} \
--cluster-name ${cluster} \
--name "default" \
--connectivity-properties ${connectivityProps}
echo "Installing extension: ${extensionName} on cluster: ${cluster}"
az stack-hci extension create \
--arc-setting-name "default" \
--cluster-name "${cluster}" \
--resource-group "${resourceGroup}" \
--name "${extensionName}" \
--auto-upgrade "true" \
--publisher "${extensionPublisher}" \
--type "${extensionType}" \
--settings "${settingsConfig}"
done
若要在資源群組下的所有系統上安裝 Azure 監視器代理程式擴充功能,請執行下列命令:
extensionName="AzureMonitorWindowsAgent"
extensionType="AzureMonitorWindowsAgent"
extensionPublisher="Microsoft.Azure.Monitor"
for cluster in ${clusters}; do
echo "Installing extension: ${extensionName} on cluster: ${cluster}"
az stack-hci extension create \
--arc-setting-name "default" \
--cluster-name "${cluster}" \
--resource-group "${resourceGroup}" \
--name "${extensionName}" \
--auto-upgrade "true" \
--publisher "${extensionPublisher}" \
--type "${extensionType}"
done
若要在資源群組下的所有系統上安裝 Azure Site Recovery 擴充功能,請執行下列命令:
asrSubscription="00000000-0000-0000-0000-000000000000" # Replace with your ASR subscription ID
asrResourceGroup="asr-rg" # Replace with your ASR resource group
asrVaultName="asr-vault" # Replace with your ASR vault name
asrLocation="East US" # Replace with your ASR Location
asrSiteId="00000000-0000-0000-0000-000000000000" # Replace with your ASR Site ID
asrSiteName="asr-site" # Replace with your Site Name
asrSitePolicyId="/subscriptions/${asrSubscription}/resourceGroups/${asrResourceGroup}/providers/Microsoft.RecoveryServices/vaults/${asrVaultName}/replicationPolicies/s-cluster-policy" # Replace with your Site Policy name
extensionName="ASRExtension"
extensionType="Windows"
extensionPublisher="Microsoft.SiteRecovery.Dra"
jsonFile="./tmp-asr.json" #Temp JSON file
echo "{\"SubscriptionId\": \"${asrSubscription}\", \"Environment\": \"AzureCloud\",\"ResourceGroup\": \"${asrResourceGroup}\",\"Location\": \"${asrLocation}\",\"SiteId\": \"${asrSiteId}\", \"SiteName\": \"${asrSiteName}\", \"PolicyId\": \"${asrSitePolicyId}\", \"PrivateEndpointStateForSiteRecovery\": \"None\" }" > ${jsonFile}
for cluster in ${clusters}; do
echo "Installing extension: ${extensionName} on cluster: ${cluster}"
az stack-hci extension create \
--arc-setting-name "default" \
--cluster-name "${cluster}" \
--resource-group "${resourceGroup}" \
--name "${extensionName}" \
--auto-upgrade "true" \
--publisher "${extensionPublisher}" \
--type "${extensionType}" \
--settings "${jsonFile}"
done
$subscription = "00000000-0000-0000-0000-000000000000" # Replace with your subscription ID
$resourceGroup = "hcicluster-rg" # Replace with your resource group name
Set-AzContext -Subscription "${subscription}"
$clusters = Get-AzResource -ResourceType "Microsoft.AzureStackHCI/clusters" -ResourceGroupName ${resourceGroup} | Select-Object -Property Name
若要在資源群組下的所有系統上安裝 Windows Admin Center 擴充功能,請執行下列命令:
若要在資源群組下的所有系統上安裝 Azure Site Recovery 擴充功能,請建立 JSON 參數檔案,然後執行下列命令:
$settings = @{
SubscriptionId = "<Replace with your Subscription Id>"
Environment = "<Replace with the cloud environment type. For example: AzureCloud>"
ResourceGroup = "<Replace with your Site Recovery Vault resource group>"
ResourceName = "<Replace with your Site Recovery Vault Name>"
Location = "<Replace with your Site Recovery Azure Region>"
SiteId = "<Replace with the ID of your recovery site>"
SiteName = "<Replace with your recovery site name>"
PolicyId = "<Replace with resource ID of your recovery site policy>"
PrivateEndpointStateForSiteRecovery = "None"
}
$extensionName = "ASRExtension"
$extensionType = "Windows"
$extensionPublisher = "Microsoft.SiteRecovery.Dra"
foreach ($cluster in $clusters) {
$clusterName = ${cluster}.Name
Write-Output ("Installing Extension '${extensionType}/${extensionPublisher}' on cluster ${clusterName}")
New-AzStackHciExtension `
-ClusterName "${clusterName}" `
-ResourceGroupName "${resourceGroup}" `
-ArcSettingName "default" `
-Name "${extensionName}" `
-ExtensionParameterPublisher "${extensionPublisher}" `
-ExtensionParameterType "${extensionType}" `
-ExtensionParameterSetting ${settings} `
-NoWait
}
subscription="00000000-0000-0000-0000-000000000000" # Replace with your subscription ID
resourceGroup="hcicluster-rg" # Replace with your resource group name
clusterName="HCICluster" # Replace with your cluster name
extensionName="AzureMonitorWindowsAgent" # Replace with the extension name
az account set --subscription "${subscription}"
若要列出系統上的所有延伸模組,請執行下列命令:
az stack-hci extension list \
--arc-setting-name "default" \
--cluster-name "${clusterName}" \
--resource-group "${resourceGroup}" \
-o table
$subscription = "00000000-0000-0000-0000-000000000000" # Replace with your subscription ID
$resourceGroup = "hcicluster-rg" # Replace with your resource group name
Set-AzContext -Subscription "${subscription}"
$clusters = Get-AzResource -ResourceType "Microsoft.AzureStackHCI/clusters" -ResourceGroupName ${resourceGroup} | Select-Object -Property Name
extensionName="AzureMonitorWindowsAgent" # Replace with the extension name
resourceGroup="hcicluster-rg" # Replace with your resource group name
clusterName="HCICluster" # Replace with your cluster name
az stack-hci extension delete \
--arc-setting-name "default" \
--name "${extensionName}" \
--cluster-name "${clusterName}" \
--resource-group "${resourceGroup}"
若要移除特定的擴充功能,例如 AzureMonitorWindowsAgent 執行下列命令:
$clusterName = "HCICluster" # Replace with your cluster name
$resourceGroup = "hcicluster-rg" # Replace with your resource group name
$extensionName = "AzureMonitorWindowsAgent"
Remove-AzStackHciExtension `
-ClusterName "${clusterName}" `
-ResourceGroupName "${resourceGroup}" `
-ArcSettingName "default" `
-Name "${extensionName}"