Menyebarkan aplikasi ke Service Fabric Mesh
Sampel skrip ini menyalin paket aplikasi ke penyimpanan citra kluster, mendaftarkan jenis aplikasi di kluster, menghapus paket aplikasi yang tidak perlu, dan membuat instans aplikasi dari jenis aplikasi tersebut. Jika ada layanan default yang didefinisikan dalam manifes aplikasi dari jenis aplikasi target, maka layanan tersebut dibuat saat ini. Sesuaikan parameter sesuai kebutuhan.
Jika diperlukan, instal modul Service Fabric PowerShell dengan SDK Service Fabric.
Sampel skrip
# Variables
$endpoint = 'mysftestcluster.southcentralus.cloudapp.azure.com:19000'
$thumbprint = '2779F0BB9A969FB88E04915FFE7955D0389DA7AF'
$packagepath="C:\Users\sfuser\Documents\Visual Studio 2017\Projects\MyApplication\MyApplication\pkg\Release"
# 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 MyApplication
# Register the application type.
Register-ServiceFabricApplicationType -ApplicationPathInImageStore MyApplication
# Remove the application package to free system resources.
Remove-ServiceFabricApplicationPackage -ImageStoreConnectionString fabric:ImageStore -ApplicationPackagePathInImageStore MyApplication
# Create the application instance.
New-ServiceFabricApplication -ApplicationName fabric:/MyApplication -ApplicationTypeName MyApplicationType -ApplicationTypeVersion 1.0.0
Membersihkan Penyebaran
Setelah sampel skrip dijalankan, skrip di Hapus aplikasi dapat digunakan untuk menghapus instans aplikasi, membatalkan pendaftaran jenis aplikasi, dan menghapus paket aplikasi dari toko gambar.
Penjelasan skrip
Skrip ini menggunakan perintah berikut. Setiap perintah dalam tabel ditautkan ke dokumentasi spesifik perintah.
Perintah | Catatan |
---|---|
Connect-ServiceFabricCluster | Membuat koneksi ke kluster Service Fabric. |
Copy-ServiceFabricApplicationPackage | Menyalin paket aplikasi ke penyimpanan gambar kluster. |
Register-ServiceFabricApplicationType | Mendaftarkan jenis aplikasi dan versi pada kluster. |
New-ServiceFabricApplication | Membuat aplikasi dari jenis aplikasi terdaftar. |
Remove-ServiceFabricApplicationPackage | Menghapus paket aplikasi Service Fabric dari penyimpanan gambar. |
Langkah berikutnya
Untuk informasi selengkapnya tentang modul Service Fabric PowerShell, lihat dokumentasi Azure PowerShell.
Sampel Powershell tambahan untuk Azure Service Fabric dapat ditemukan di sampel Azure PowerShell.