使用PowerShell将应用程序部署到Service Fabric

4

我已经在Azure上安装并运行了Service Fabric。同时,我的Visual Studio解决方案有两个项目:Service Fabric和Web Service。

我想要将服务部署到Azure的Service Fabric中。

当我右键点击Service Fabric项目并点击“发布”时,服务能够平稳地部署到云端的可靠平台上。我想使用PowerShell实现同样的操作。

看来,我需要运行以下脚本:

# Connect to the cluster using a client certificate.
Connect-ServiceFabricCluster -ConnectionEndpoint $endpoint `
      -KeepAliveIntervalInSec 10 `
      -X509Credential -ServerCertThumbprint $thumbprint `
      -FindType FindByThumbprint -FindValue $thumbprint `
      -StoreLocation CurrentUser -StoreName My

# Copy the application package to the cluster image store.
Copy-ServiceFabricApplicationPackage $packagepath -ImageStoreConnectionString fabric:ImageStore -ApplicationPackagePathInImageStore $packagename

# Register the application type.
Register-ServiceFabricApplicationType -ApplicationPathInImageStore $packagename

# Create the service instance.
$appName = <name that I see in fabric explorer under 'typeName' in azure>
New-ServiceFabricService -ApplicationName fabric:/$appName -ServiceName fabric:/$appName/MyApp -ServiceTypeName $serviceTypeName -Stateless -PartitionSchemeSingleton -InstanceCount -1

在运行脚本之前,我右键单击我的布料应用程序并选择“打包”。
我的脚本的最后一条命令失败,并显示“找不到应用程序”。
可能缺少什么?

你是否首先使用 msbuild HelloWorld.sfproj /t:Package 命令构建了一个包? - LoekD
2个回答

4

一旦您构建并准备好了软件包,您可以尝试以下命令以使用PowerShell脚本部署pkg。

如果您还没有尝试过以下选项,请尝试并查看是否有效。

为了运行脚本,需要满足以下先决条件:

  • 您的群集正在运行。

  • 群集已部署所有必要的证书(例如用于SSL端点的证书,如果有)

  • 您已准备好ARM模板和参数文件。

  • 您具有部署新资源所需的必要权限,即Contributor角色(在订阅或资源组级别)

  • 您已创建目标资源组。

一旦检查完上述内容,请执行以下命令:

Copy-ServiceFabricApplicationPackage

Register-ServiceFabricApplicationType

New-ServiceFabricApplication

如果这对您不起作用,请查看以下网站以查看是否有帮助。

使用PowerShell部署应用程序

使用资源管理器模板和Azure PowerShell部署资源


2

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接