共用方式為

创建 Service Fabric 群集

此示例Azure PowerShell脚本创建使用 X.509 证书保护的五节点服务Fabric群集。 该命令将创建一个自签名证书,并将其上传到新的 Key Vault。 该证书也会复制到本地目录。 设置 -OS 参数,以选择群集节点上运行的 Windows 或 Linux 版本。 根据需要自定义参数。

注意

建议使用 Azure Az PowerShell 模块与Azure交互。 若要开始,请参阅 Install Azure PowerShell。 若要了解如何迁移到 Az PowerShell 模块,请参阅 Migrate Azure PowerShell从 AzureRM 迁移到 Az

如果需要,请使用 Azure PowerShell 指南中找到的说明安装Azure PowerShell,然后运行 Connect-AzAccount -Environment AzureChinaCloud 来创建与Azure的连接。

示例脚本

#Provide the subscription Id
$subscriptionId = 'yourSubscriptionId'

# Certificate variables.
$certpwd="Password#1234" | ConvertTo-SecureString -AsPlainText -Force
$certfolder="c:\mycertificates\"

# Variables for VM admin.
$adminuser="vmadmin"
$adminpwd="Password#1234" | ConvertTo-SecureString -AsPlainText -Force 

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

# Set the number of cluster nodes. Possible values: 1, 3-99
$clustersize=5 

# Set the context to the subscription Id where the cluster will be created
Select-AzSubscription -SubscriptionId $subscriptionId

# Create the Service Fabric cluster.
New-AzServiceFabricCluster -Name $clustername -ResourceGroupName $groupname -Location $clusterloc `
-ClusterSize $clustersize -VmUserName $adminuser -VmPassword $adminpwd -CertificateSubjectName $subname `
-CertificatePassword $certpwd -CertificateOutputFolder $certfolder `
-OS WindowsServer2016DatacenterwithContainers -VmSku $vmsku -KeyVaultName $vaultname

清理部署环境

运行脚本示例后,可以使用以下命令删除资源组、群集和所有相关资源。

$groupname="mysfclustergroup"
Remove-AzResourceGroup -Name $groupname -Force

脚本说明

此脚本使用以下命令。 表中的每条命令均链接到特定于命令的文档。

命令 说明
New-AzServiceFabricCluster 创建新的Service Fabric群集。

后续步骤

有关Azure PowerShell模块的详细信息,请参阅 Azure PowerShell 文档

可以在 Azure PowerShell 示例中找到Azure Service Fabric的其他Azure PowerShell示例。