將應用程式部署到 Service Fabric 叢集Deploy an application to a Service Fabric cluster

這個範例指令碼會將應用程式封裝複製到叢集映像存放區、在叢集中註冊應用程式類型,並從應用程式類型建立應用程式執行個體。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 SDKIf needed, install the Service Fabric CLI.

範例指令碼Sample script

#!/bin/bash

# Select cluster
sfctl cluster select \
    --endpoint http://svcfab1.westus2.cloudapp.azure.com: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.