透過 Azure CLI 建立安全的 Service Fabric Linux 叢集

此命令會建立自我簽署的憑證,然後將其加入金鑰保存庫並在本機下載憑證。 新的憑證會用來在部署叢集時保護叢集。 您也可以使用現有的憑證,而不用建立新的。 無論是哪一方法,憑證的主體名稱必須與您用來存取 Service Fabric 叢集的網域相符。 必須如此相符,才能為叢集的 HTTPS 管理端點和 Service Fabric Explorer 提供 TLS。 您無法從 CA 取得 .cloudapp.azure.com 網域的 TLS/SSL 憑證。 您必須為您的叢集取得自訂網域名稱。 當您向 CA 要求憑證時,憑證的主體名稱必須與用於您叢集的自訂網域名稱相符。

視需要安裝 Azure CLI

範例指令碼

#!/bin/bash

# Variables
ResourceGroupName="aztestclustergroup" 
ClusterName="aztestcluster" 
Location="southcentralus" 
Password="q6D7nN%6ck@6" 
Subject="aztestcluster.southcentralus.cloudapp.azure.com" 
VaultName="aztestkeyvault" 
VmPassword="Mypa$$word!321"
VmUserName="sfadminuser"

# Create resource group
az group create --name $ResourceGroupName --location $Location 

# Create secure five node Linux cluster. Creates a key vault in a resource group
# and creates a certficate in the key vault. The certificate's subject name must match 
# the domain that you use to access the Service Fabric cluster.  The certificate is downloaded locally.
az sf cluster create --resource-group $ResourceGroupName --location $Location \ 
  --certificate-output-folder . --certificate-password $Password --certificate-subject-name $Subject \
  --cluster-name $ClusterName --cluster-size 5 --os UbuntuServer1604 --vault-name $VaultName \ 
  --vault-resource-group $ResourceGroupName --vm-password $VmPassword --vm-user-name $VmUserName
    

清除部署

在執行過指令碼範例之後,您可以使用下列命令來移除資源群組、叢集和所有相關資源。

ResourceGroupName = "aztestclustergroup"
az group delete --name $ResourceGroupName

指令碼說明

此指令碼會使用下列命令。 下表中的每個命令都會連結至命令特定的文件。

Command 注意
az sf cluster create 建立新的 Service Fabric 叢集。

下一步

您可以在 Service Fabric CLI 範例中找到適用於 Azure Service Fabric 的其他 Service Fabric CLI 範例。