使用 Service Fabric CLI 将应用程序部署到 Service Fabric 群集Deploy an application to a Service Fabric cluster using the Service Fabric CLI

此示例脚本将应用程序包复制到群集映像存储,在群集中注册应用程序类型,并从应用程序类型创建应用程序实例。This sample script copies an application package to a cluster image store, registers the application type in the cluster, and creates an application instance from the application type. 此时还将创建任何默认服务。Any default services are also created at this time.

如果需要,请安装 Service Fabric CLIIf needed, install the Service Fabric CLI.

示例脚本Sample script

#!/bin/bash

# Select cluster
sfctl cluster select \
    --endpoint http://svcfab1.chinanorth2.cloudapp.chinacloudapi.cn:19080

# Upload the application files to the image store
# (note the last folder name, Debug in this example)
sfctl application upload \
    --path  C:\Code\svcfab-vs\svcfab-vs\pkg\Debug \
    --show-progress

# Register the application (manifest files) from the image store
# (Note the last folder from the previous command is used: Debug)
sfctl application provision \
    --application-type-build-path Debug \
    --timeout 500

# Create an instance of the registered application and 
# auto deploy any defined services
sfctl application create \
    --app-name fabric:/MyApp \
    --app-type MyAppType \
    --app-version 1.0.0

清理部署Clean up deployment

完成后,可使用删除脚本删除应用程序。When done, the remove script can be used to remove the application. 删除脚本会删除应用程序实例、注销应用程序类型,并从映像存储中删除应用程序包。The remove script deletes the application instance, unregisters the application type, and deletes the application package from the image store.

后续步骤Next steps

有关详细信息,请参阅 Service Fabric CLI 文档For more information, see the Service Fabric CLI documentation.

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