【问题标题】:Deploy app to service fabric with PowerShell使用 PowerShell 将应用程序部署到服务结构
【发布时间】:2019-08-31 09:15:57
【问题描述】:

我已在 Azure 中启动并运行服务结构。我也有两个项目的 Visual Studio 解决方案:Service Fabric 和 Web Service。 我想将服务部署到 azure 中的服务结构。 当我右键单击我的服务结构项目并单击“发布”时,服务会顺利部署到云结构。我想对 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 构建了一个包?

标签: powershell azure-service-fabric


【解决方案1】:

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

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

运行脚本需要几个先决条件:

  • 您的集群已启动并正在运行。

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

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

  • 您拥有部署新资源所需的权限, 即贡献者角色(在订阅或资源级别 组)

  • 您已创建目标资源组

检查上述内容后,执行以下命令:

Copy-ServiceFabricApplicationPackage

注册-ServiceFabricApplicationType

New-ServiceFabricApplication

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

Deploy applications using PowerShell

Deploy resources with Resource Manager templates and Azure PowerShell

【讨论】:

    【解决方案2】:

    问题是我在命令New-ServiceFabricService中使用了错误的ApplicationNameServiceName

    为了找出正确的值,我运行了Get-ServiceFabricApplicationGet-ServiceFabricService

    这些页面对于构建脚本故障排除非常有帮助:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-06-05
      • 2021-10-13
      • 1970-01-01
      • 2015-07-26
      • 2021-01-17
      • 1970-01-01
      • 2023-03-27
      • 2019-08-09
      相关资源
      最近更新 更多