zoukankan      html  css  js  c++  java
  • Powershell Deploy Service Fabric Application To Local Cluster

    之前写过一篇用 Powershell 部署 Service Fabric Application 到本地集群的随笔,感觉过程有点复杂,这次将流程简化,只需要将应用程序打包,加上配置文件就可以了。

     

    # 该脚本用于部署到本机集群,若有错误,欢迎指正。

    # Variables
    # 自行修改下面参数

    ## 应用打包后的文件夹路径
    $PackagePath="C:pkgRelease"

    ## 应用配置文件路径,对应 Service Fabric App/ApplicationParameters/*.xml
    $ApplicationParameterFilePath = "C:ApplicationParametersLocal.1Node.xml"

    ######################### 以下内容请不要轻易修改 #########################

    $Endpoint = 'localhost:19000'
    $CopyPackageTimeoutSec = 6000
    $CompressPackage = $false

    #references
    try
    {
      ## 该脚本是安装 Service Fabric SDK 后生成的,以下是默认路径,如安装时修改了安装路径,请自行修改。
      . "C:Program FilesMicrosoft SDKsService FabricToolsPSModuleServiceFabricSDKUtilities.ps1"
    }
    catch
    {
      Write-Warning 'Can not reference files.'
      throw
    }

    # Connect to the cluster using a client certificate.
    Connect-ServiceFabricCluster -ConnectionEndpoint $Endpoint

    # Get Application Type Name, Application Name and Application Parameters.
    try
    {
      $Names = Get-NamesFromApplicationManifest -ApplicationManifestPath "$PackagePathApplicationManifest.xml"
      $ApplicationTypeName = $Names.ApplicationTypeName
      $ApplicationTypeVersion = $Names.ApplicationTypeVersion

      $ApplicationName = ([xml] (Get-Content $ApplicationParameterFilePath)).Application.Name

      $ApplicationParameter = Get-ApplicationParametersFromApplicationParameterFile $ApplicationParameterFilePath
    }
    catch
    {
      Write-Warning 'Unable to read Application Type Name, Application Name and Application Parameters.'
      throw
    }

    try
    {
      # Copy the application package to the cluster image store.
      Write-Host 'Copying application to image store...'
      Copy-ServiceFabricApplicationPackage -ApplicationPackagePath $PackagePath -ApplicationPackagePathInImageStore $ApplicationTypeName -TimeOutSec $CopyPackageTimeoutSec -CompressPackage:$CompressPackage
    }
    catch
    {
      Write-Error 'Copying application to image store failed.'
      throw
    }

    try
    {
      # Register the application type.
      Write-Host 'Registering application type...'
      Register-ServiceFabricApplicationType -ApplicationPathInImageStore $ApplicationTypeName -TimeoutSec 6000
    }
    catch
    {
      Write-Error 'Registering application type failed.'
      throw
    }

    try
    {
      # Remove the application package to free system resources.
      Write-Host 'Removing application package from image store...'
      Remove-ServiceFabricApplicationPackage -ApplicationPackagePathInImageStore $ApplicationTypeName -TimeoutSec 6000
    }
    catch
    {
      Write-Error 'Removing application package from image store failed.'
      throw
    }

    # Create the application instance.
    Write-Host 'Creating application...'
    New-ServiceFabricApplication -ApplicationName $ApplicationName -ApplicationTypeName $ApplicationTypeName -ApplicationTypeVersion $ApplicationTypeVersion -ApplicationParameter $ApplicationParameter -TimeoutSec 6000
    if(!$?)
    {
      throw "Creation of application failed."
    }

    Write-Host 'Create application succeeded.'

  • 相关阅读:
    android 布局 使用 viewPager 时,如何解决 和 子页面 长按滑动 冲突问题
    C++ 与 php 的交互 之----- C++ 异步获取 网页文字内容,异步获取 php 的 echo 值。
    站在巨人的肩膀上---重新自定义 android- ExpandableListView 收缩类,实现列表的可收缩扩展
    C/C++ char a[ ] 和 char *a 的差别,改变 char *a爆内存错误的原因
    android 真机调试出现错误 INSTALL_FAILED_INSUFFICIENT_STORAGE 的解决方法。
    android 如何获取手机的图片、视频、音乐
    《C程序设计语言》练习1-5
    《C 程序设计语言》练习1-4
    《C 程序设计语言》练习1-3
    关于 Cantor 集不可数的新观点
  • 原文地址:https://www.cnblogs.com/ycm-up/p/9558706.html
Copyright © 2011-2022 走看看