将应用程序证书添加到 Service Fabric 群集Add an application certificate to a Service Fabric cluster

此示例脚本在指定的 Azure Key Vault 中创建一个自签名证书,并将它安装到 Service Fabric 群集的所有节点上。This sample script creates a self-signed certificate in the specified Azure key vault and installs it to all nodes of the Service Fabric cluster. 该证书还会下载到本地文件夹。The certificate also downloads to a local folder. 已下载证书的名称与 Key Vault 中证书的名称相同。The name of the downloaded certificate is the same as the name of the certificate in the key vault. 根据需要自定义参数。Customize the parameters as needed.

必要时,请使用 Azure PowerShell 指南中的说明安装 Azure PowerShell,并运行 Connect-AzureRmAccount -Environment AzureChinaCloud 创建与 Azure 的连接。If needed, install the Azure PowerShell using the instruction found in the Azure PowerShell guide and then run Connect-AzureRmAccount -Environment AzureChinaCloud to create a connection with Azure.

示例脚本Sample script


# Variables for common values.
$clusterloc="chinaeast"
$groupname="mysfclustergroup"
$clustername = "mysfcluster"
$vaultname = "mykeyvault"
$subname="$clustername.$clusterloc.cloudapp.chinacloudapi.cn"

# Certificate variables.
$appcertpwd = ConvertTo-SecureString -String 'Password#1234' -AsPlainText -Force
$appcertfolder="c:\myappcertificates\"

# Create a new self-signed certificate and add it to all the VMs in the cluster.
Add-AzureRmServiceFabricApplicationCertificate -ResourceGroupName $groupname -Name $clustername `
    -KeyVaultName $vaultname -KeyVaultResouceGroupName $groupname -CertificateSubjectName $subname `
    -CertificateOutputFolder $appcertfolder -CertificatePassword $appcertpwd

脚本说明Script explanation

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

命令Command 注释Notes
Add-AzureRmServiceFabricApplicationCertificateAdd-AzureRmServiceFabricApplicationCertificate 将新的应用程序证书添加到构成群集的虚拟机规模集。Add a new application certificate to the virtual machine scale set that make up the cluster.

后续步骤Next steps

有关 Azure PowerShell 模块的详细信息,请参阅 Azure PowerShell 文档For more information on the Azure PowerShell module, see Azure PowerShell documentation.

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