使用 Service Fabric CLI 更新应用程序Update an application using the Service Fabric CLI

此示例脚本会上传现有应用程序的新版本,然后使用新位升级已部署的应用程序。This sample script uploads a new version of an existing application, and then upgrades a deployed application with the new bits.

Important

可以使用两个 CLI 实用工具来与 Service Fabric 交互。There are two CLI utilities used to interact with Service Fabric. Azure CLI 用于管理 Azure 资源,例如 Azure 托管的 Service Fabric 群集。Azure CLI is used to manage Azure resources, such as an Azure-hosted Service Fabric cluster. Service Fabric CLI 用于直接连接到 Service Fabric 群集(不管托管在哪个位置)和管理群集、应用程序与服务。Service Fabric CLI is used to directly connect to the Service Fabric cluster (regardless of where it's hosted) and manage the cluster, applications, and services.

示例脚本Sample script

#!/bin/bash

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

# Upload the latest bits of an application
sfctl application upload --path ~/app_package_dir_2

# Provision the new application
sfctl application provision --application-type-build-path app_package_dir_2

# Upgrade an existing up with the new version
sfctl application upgrade --app-id TestApp --app-version 2.0.0 --parameters "{\"test\":\"value\"}" --mode Monitored

后续步骤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.