在 Azure 中创建安全的 Service Fabric Linux 群集Create a secure Service Fabric Linux cluster in Azure

此命令创建一个自签名证书,将其添加到密钥保管库并在本地下载该证书。This command creates a self-signed certificate, adds it to a key vault and downloads the certificate locally. 新证书用于在群集部署时保护群集。The new certificate is used to secure the cluster when it deploys. 也可以使用现有证书而不是创建一个新证书。You can also use an existing certificate instead of creating a new one. 不管怎样,证书的使用者名称都必须与用于访问 Service Fabric 群集的域匹配。Either way, the certificate's subject name must match the domain that you use to access the Service Fabric cluster. 只有满足此匹配,才能为群集的 HTTPS 管理终结点和 Service Fabric Explorer 提供 SSL。This match is required to provide an SSL for the cluster's HTTPS management endpoints and Service Fabric Explorer. 无法从 CA 获取 .cloudapp.chinacloudapi.cn 域的 SSL 证书。You cannot obtain an SSL certificate from a CA for the .cloudapp.chinacloudapi.cn domain. 必须获取群集的自定义域名。You must obtain a custom domain name for your cluster. 从 CA 请求证书时,该证书的使用者名称必须与用于群集的自定义域名匹配。When you request a certificate from a CA, the certificate's subject name must match the custom domain name that you use for your cluster.

根据需要安装 Azure CLIIf needed, install the Azure CLI.

示例脚本Sample script

#!/bin/bash

# Variables
ResourceGroupName="aztestclustergroup" 
ClusterName="aztestcluster" 
Location="chinaeast" 
Password="q6D7nN%6ck@6" 
Subject="aztestcluster.chinaeast.cloudapp.chinacloudapi.cn" 
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

清理部署Clean up deployment

运行脚本示例后,可以使用以下命令删除资源组、群集以及所有相关资源。After the script sample has been run, the following command can be used to remove the resource group, cluster, and all related resources.

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

脚本说明Script explanation

此脚本使用以下命令。This script uses the following commands. 表中的每条命令均链接到特定于命令的文档。Each command in the table links to command specific documentation.

CommandCommand 说明Notes
az sf cluster createaz sf cluster create 新建 Service Fabric 群集。Creates a new Service Fabric cluster.

后续步骤Next steps

Service Fabric CLI 示例中可找到 Azure Service Fabric 的其他 Service Fabric CLI 示例。Additional Service Fabric CLI samples for Azure Service Fabric can be found in the Service Fabric CLI samples.