使用 PowerShell 部署和删除应用程序Deploy and remove applications using PowerShell


打包应用程序类型后,即可部署到 Azure Service Fabric 群集中。Once an application type has been packaged, it's ready for deployment into an Azure Service Fabric cluster. 部署涉及以下三个步骤:Deployment involves the following three steps:

  1. 将应用程序包上传到映像存储区。Upload the application package to the image store.
  2. 使用映像存储区相对路径注册应用程序类型。Register the application type with image store relative path.
  3. 创建应用程序实例。Create the application instance.

不再需要部署的应用程序后,可以删除应用程序实例及其应用程序类型。Once the deployed application is no longer required, you can delete the application instance and its application type. 从群集中完全删除某个应用程序涉及以下步骤:To completely remove an application from the cluster involves the following steps:

  1. 删除正在运行的应用程序实例。Remove (or delete) the running application instance.
  2. 如果不再需要该应用程序类型,则将其取消注册。Unregister the application type if you no longer need it.
  3. 从映像存储区中删除应用程序包。Remove the application package from the image store.

如果使用 Visual Studio 来部署和调试本地开发群集上的应用程序,则将通过 PowerShell 脚本自动处理上述所有步骤。If you use Visual Studio for deploying and debugging applications on your local development cluster, all the preceding steps are handled automatically through a PowerShell script. 可在应用程序项目的 Scripts 文件夹中找到此脚本。This script is found in the Scripts folder of the application project. 本文提供了有关这些脚本正在执行什么操作的背景,以便可以在 Visual Studio 外部执行相同的操作。This article provides background on what that script is doing so that you can perform the same operations outside of Visual Studio.

部署应用程序的另一种方法是使用外部预配。Another way to deploy an application is by using external provision. 应用程序包可以打包为 sfpkg 并上传到外部存储区。The application package can be packaged as sfpkg and uploaded to an external store. 在这种情况下,不需要上传到映像存储区。In this case, upload to the image store is not needed. 部署需要以下步骤:Deployment needs the following steps:

  1. sfpkg 上传到外部存储区。Upload the sfpkg to an external store. 外部存储区可以是公开了 REST http 或 https 终结点的任何存储区。The external store can be any store that exposes a REST http or https endpoint.
  2. 使用外部下载 URI 和应用程序类型信息注册应用程序类型。Register the application type using the external download URI and the application type information.
  3. 创建应用程序实例。Create the application instance.

若要清理,请删除应用程序实例并取消注册应用程序类型。For cleanup, remove the application instances and unregister the application type. 由于已将包复制到映像存储区,因此没有要清理的临时位置。Because the package was not copied to the image store, there is no temporary location to cleanup. 从外部存储区预配的功能是从 Service Fabric 6.1 版开始提供的。Provisioning from external store is available starting with Service Fabric version 6.1.

Note

Visual Studio 目前不支持外部预配。

连接至群集Connect to the cluster

在运行本文中的任何 PowerShell 命令之前,请始终先使用 Connect-ServiceFabricCluster 连接到 Service Fabric 群集。Before you run any PowerShell commands in this article, always start by using Connect-ServiceFabricCluster to connect to the Service Fabric cluster. 若要连接到本地部署群集,请运行以下命令:To connect to the local development cluster, run the following:

PS C:\>Connect-ServiceFabricCluster

有关连接到远程群集或连接到使用 Azure Active Directory、X509 证书或 Windows Active Directory 保护的群集的示例,请参阅连接到安全群集For examples of connecting to a remote cluster or cluster secured using Azure Active Directory, X509 certificates, or Windows Active Directory see Connect to a secure cluster.

上传应用程序包Upload the application package

上传应用程序包时会将该包放在一个可由内部 Service Fabric 组件访问的位置。Uploading the application package puts it in a location that's accessible by internal Service Fabric components. 如果要在本地验证应用程序包,请使用 Test-ServiceFabricApplicationPackage cmdlet。If you want to verify the application package locally, use the Test-ServiceFabricApplicationPackage cmdlet.

Copy-ServiceFabricApplicationPackage 命令用来将应用程序包上传到群集映像存储。The Copy-ServiceFabricApplicationPackage command uploads the application package to the cluster image store.

假设在 Visual Studio 2015 中生成并打包名为 MyApplication 的应用程序。Suppose you build and package an application named MyApplication in Visual Studio 2015. 默认情况下,ApplicationManifest.xml 中列出的应用程序类型名称为“MyApplicationType”。By default, the application type name listed in the ApplicationManifest.xml is "MyApplicationType". 应用程序包(其中包含必需的应用程序清单、服务清单以及代码/配置/数据包)位于 C:\Users<username>\Documents\Visual Studio 2015\Projects\MyApplication\MyApplication\pkg\Debug 中。The application package, which contains the necessary application manifest, service manifests, and code/config/data packages, is located in C:\Users<username>\Documents\Visual Studio 2015\Projects\MyApplication\MyApplication\pkg\Debug.

以下命令列出应用程序包的内容:The following command lists the contents of the application package:

PS C:\> $path = 'C:\Users\<user\>\Documents\Visual Studio 2015\Projects\MyApplication\MyApplication\pkg\Debug'
PS C:\> tree /f $path
Folder PATH listing for volume OSDisk
Volume serial number is 0459-2393
C:\USERS\USER\DOCUMENTS\VISUAL STUDIO 2015\PROJECTS\MYAPPLICATION\MYAPPLICATION\PKG\DEBUG
│   ApplicationManifest.xml
│
└───Stateless1Pkg
    │   ServiceManifest.xml
    │
    ├───Code
    │       Microsoft.ServiceFabric.Data.dll
    │       Microsoft.ServiceFabric.Data.Interfaces.dll
    │       Microsoft.ServiceFabric.Internal.dll
    │       Microsoft.ServiceFabric.Internal.Strings.dll
    │       Microsoft.ServiceFabric.Services.dll
    │       ServiceFabricServiceModel.dll
    │       Stateless1.exe
    │       Stateless1.exe.config
    │       Stateless1.pdb
    │       System.Fabric.dll
    │       System.Fabric.Strings.dll
    │
    └───Config
            Settings.xml

如果应用程序包很大,并且/或者包含许多文件,可以进行压缩If the application package is large and/or has many files, you can compress it. 压缩可以减小文件大小,减少文件数量。The compression reduces the size and the number of files. 附带作用是加快注册和注销应用程序类型。The side effect is that registering and un-registering the application type are faster. 上传时间目前可能会降低,尤其是当包含压缩包的时间时。Upload time may be slower currently, especially if you include the time to compress the package.

若要压缩包,请使用同一 Copy-ServiceFabricApplicationPackage 命令。To compress a package, use the same Copy-ServiceFabricApplicationPackage command. 可以使用 SkipCopy 标记独立于上传进行压缩,也可以与上传操作配合使用进行压缩。Compression can be done separate from upload, by using the SkipCopy flag, or together with the upload operation. 对压缩包应用压缩不会执行任何操作。Applying compression on a compressed package is no-op. 若要解压缩压缩包,请将同一 Copy-ServiceFabricApplicationPackage 命令与 UncompressPackage 切换配合使用。To uncompress a compressed package, use the same Copy-ServiceFabricApplicationPackage command with the UncompressPackage switch.

以下 cmdlet 可压缩包,而不会将包复制到映像存储区。The following cmdlet compresses the package without copying it to the image store. 此包中现在包括 Code 包和 Config 包的压缩文件。The package now includes zipped files for the Code and Config packages. 不会压缩应用程序和服务清单,因为许多内部操作均需要使用它们(例如,包共享、应用程序类型名称和某些验证的版本提取)。The application and the service manifests are not zipped, because they are needed for many internal operations (like package sharing, application type name and version extraction for certain validations). 压缩清单会使这些操作无效。Zipping the manifests would make these operations inefficient.

PS C:\> Copy-ServiceFabricApplicationPackage -ApplicationPackagePath $path -CompressPackage -SkipCopy
PS C:\> tree /f $path
Folder PATH listing for volume OSDisk
Volume serial number is 0459-2393
C:\USERS\USER\DOCUMENTS\VISUAL STUDIO 2015\PROJECTS\MYAPPLICATION\MYAPPLICATION\PKG\DEBUG
|   ApplicationManifest.xml
|
└───Stateless1Pkg
       Code.zip
       Config.zip
       ServiceManifest.xml

对于大型应用程序包,压缩操作将耗费时间。For large application packages, the compression takes time. 为获得最佳结果,请使用快速 SSD 驱动器。For best results, use a fast SSD drive. 压缩时间和压缩包的大小也会因包内容而有所不同。The compression times and the size of the compressed package also differ based on the package content. 例如,以下是某些包的压缩统计信息,其中显示初始大小和压缩包大小,及压缩时间。For example, here is compression statistics for some packages, which show the initial and the compressed package size, with the compression time.

初始大小 (MB)Initial size (MB) 文件计数File count 压缩时间Compression Time 压缩包大小 (MB)Compressed package size (MB)
100100 100100 00:00:03.354759200:00:03.3547592 6060
512512 100100 00:00:16.385030300:00:16.3850303 307307
10241024 500500 00:00:32.590795000:00:32.5907950 615615
20482048 10001000 00:01:04.377555400:01:04.3775554 12311231
50125012 100100 00:02:45.295128800:02:45.2951288 30743074

对包进行压缩后,便可根据需要将其上传到一个或多个 Service Fabric 群集。Once a package is compressed, it can be uploaded to one or multiple Service Fabric clusters as needed. 压缩包和未压缩包的部署机制相同。The deployment mechanism is same for compressed and uncompressed packages. 压缩包同样存储在群集映像存储区中。Compressed packages are stored as such in the cluster image store. 运行应用程序之前,包在节点上未压缩。The packages are uncompressed on the node, before the application is run.

以下示例将包上传到映像存储区中名为“MyApplicationV1”的文件夹中:The following example uploads the package to the image store, into a folder named "MyApplicationV1":

PS C:\> Copy-ServiceFabricApplicationPackage -ApplicationPackagePath $path -ApplicationPackagePathInImageStore MyApplicationV1 -TimeoutSec 1800

如果未指定 -ApplicationPackagePathInImageStore 参数,则应用程序包将复制到映像存储中的“Debug”文件夹。If you do not specify the -ApplicationPackagePathInImageStore parameter, the application package is copied into the "Debug" folder in the image store.

Note

如果 PowerShell 会话已连接到 Service Fabric 群集,Copy-ServiceFabricApplicationPackage 会自动检测相应的映像存储区连接字符串。 对于版本低于 5.6 的 Service Fabric,必须显式提供 -ImageStoreConnectionString 参数。

PS C:\> Copy-ServiceFabricApplicationPackage -ApplicationPackagePath $path -ApplicationPackagePathInImageStore MyApplicationV1 -ImageStoreConnectionString (Get-ImageStoreConnectionStringFromClusterManifest(Get-ServiceFabricClusterManifest)) -TimeoutSec 1800

Service Fabric SDK PowerShell 模块中包含的 Get-ImageStoreConnectionStringFromClusterManifest cmdlet,用于获取映像存储连接字符串。 要导入 SDK 模块,请运行:

Import-Module "$ENV:ProgramFiles\Microsoft SDKs\Service Fabric\Tools\PSModule\ServiceFabricSDK\ServiceFabricSDK.psm1"

有关映像存储和映像存储连接字符串的补充信息,请参阅了解映像存储连接字符串

上传包所费时间取决于多种因素。The time it takes to upload a package differs depending on multiple factors. 其中一些因素是包中文件数、包大小和文件大小。Some of these factors are the number of files in the package, the package size, and the file sizes. 源计算机与 Service Fabric 群集之间的网络速度也会影响上传时间。The network speed between the source machine and the Service Fabric cluster also impacts the upload time. 默认 Copy-ServiceFabricApplicationPackage 的超时为 30 分钟。The default timeout for Copy-ServiceFabricApplicationPackage is 30 minutes. 根据上述因素,可能需要增加超时。Depending on the described factors, you may have to increase the timeout. 如果在复制调用中对包进行压缩,还需要考虑压缩时间。If you are compressing the package in the copy call, you need to also consider the compression time.

注册应用程序包Register the application package

应用程序清单中声明的应用程序类型和版本会在注册应用程序包时可供使用。The application type and version declared in the application manifest become available for use when the application package is registered. 系统会读取上一步中上传的程序包,验证此包,处理包的内容,并将已处理的包复制到内部系统位置。The system reads the package uploaded in the previous step, verifies the package, processes the package contents, and copies the processed package to an internal system location.

运行 Register-ServiceFabricApplicationType cmdlet 以在群集中注册应用程序类型并使其可用于部署:Run the Register-ServiceFabricApplicationType cmdlet to register the application type in the cluster and make it available for deployment:

注册复制到映像存储区的应用程序包Register the application package copied to image store

当包以前已复制到映像存储区时,注册操作会指定映像存储区中的相对路径。When a package was previously copied to the image store, the register operation specifies the relative path in the image store.

PS C:\> Register-ServiceFabricApplicationType -ApplicationPathInImageStore MyApplicationV1
Register application type succeeded

“MyApplicationV1”是映像存储中应用程序包所在的文件夹。"MyApplicationV1" is the folder in the image store where the application package is located. 现在已在群集中注册了名为“MyApplicationType”且版本为“1.0.0”(两者都可以在应用程序清单中找到)的应用程序类型。The application type with name "MyApplicationType" and version "1.0.0" (both are found in the application manifest) is now registered in the cluster.

注册复制到外部存储区的应用程序包Register the application package copied to an external store

从 Service Fabric 6.1 版开始,预配支持从外部存储区下载包。Starting with Service Fabric version 6.1, provision supports downloading the package from an external store. 下载 URI 表示 sfpkg 应用程序包的路径,可使用 HTTP 或 HTTPS 协议从该处下载应用程序包。The download URI represents the path to the sfpkg application package from where the application package can be downloaded using HTTP or HTTPS protocols. 包必须之前已上传到此外部位置。The package must have been previously uploaded to this external location. 该 URI 必须允许读取访问权限,因此 Service Fabric 可以下载该文件。The URI must allow READ access so Service Fabric can download the file. sfpkg 文件必须具有扩展名“.sfpkg”。The sfpkg file must have the extension ".sfpkg". 预配操作应包括应用程序类型信息,该信息可在应用程序清单中找到。The provision operation should include the application type information, as found in the application manifest.

PS C:\> Register-ServiceFabricApplicationType -ApplicationPackageDownloadUri "https://sftestresources.blob.core.chinacloudapi.cn:443/sfpkgholder/MyAppPackage.sfpkg" -ApplicationTypeName MyApp -ApplicationTypeVersion V1 -Async

Register-ServiceFabricApplicationType 命令只有在系统成功注册应用程序包后才会返回。The Register-ServiceFabricApplicationType command returns only after the system has successfully registered the application package. 注册花费的时间取决于应用程序包的大小和内容。How long registration takes depends on the size and contents of the application package. 如果需要,-TimeoutSec 参数可用于提供更长的超时(默认超时为 60 秒)。If needed, the -TimeoutSec parameter can be used to supply a longer timeout (the default timeout is 60 seconds).

如果在处理大型应用程序包,或者遇到超时,请使用 -Async 参数。If you have a large application package or if you are experiencing timeouts, use the -Async parameter. 该命令会在群集接受注册命令时返回。The command returns when the cluster accepts the register command. 注册操作会根据需要继续。The register operation continues as needed. Get-ServiceFabricApplicationType 命令将列出应用程序类型版本及其注册状态。The Get-ServiceFabricApplicationType command lists the application type versions and their registration status. 此命令可用于确定注册的完成时间。You can use this command to determine when the registration is done.

PS C:\> Get-ServiceFabricApplicationType

ApplicationTypeName    : MyApplicationType
ApplicationTypeVersion : 1.0.0
Status                 : Available
DefaultParameters      : { "Stateless1_InstanceCount" = "-1" }

从映像存储中删除应用程序包Remove an application package from the image store

如果包已复制到映像存储区,则应在成功注册该应用程序后将其从临时位置中删除。If a package was copied to the image store, you should remove it from the temporary location after the application is successfully registered. 从映像存储区中删除应用程序包可以释放系统资源。Deleting application packages from the image store frees up system resources. 保留未使用的应用程序包会占用磁盘存储空间,导致应用程序出现性能问题。Keeping unused application packages consumes disk storage and leads to application performance issues.

PS C:\>Remove-ServiceFabricApplicationPackage -ApplicationPackagePathInImageStore MyApplicationV1

创建应用程序Create the application

可以使用 New-ServiceFabricApplication cmdlet 通过已成功注册的任何应用程序类型版本来实例化应用程序。You can instantiate an application from any application type version that has been registered successfully by using the New-ServiceFabricApplication cmdlet. 每个应用程序的名称必须以“fabric:”方案开头,并且必须对每个应用程序实例是唯一的。The name of each application must start with the "fabric:" scheme and must be unique for each application instance. 还会创建目标应用程序类型的应用程序清单中定义的任何默认服务。Any default services defined in the application manifest of the target application type are also created.

PS C:\> New-ServiceFabricApplication fabric:/MyApp MyApplicationType 1.0.0

ApplicationName        : fabric:/MyApp
ApplicationTypeName    : MyApplicationType
ApplicationTypeVersion : 1.0.0
ApplicationParameters  : {}

可以为已注册应用程序类型的任何给定版本创建多个应用程序实例。Multiple application instances can be created for any given version of a registered application type. 每个应用程序实例都将隔离运行,具有其自己的工作目录和进程。Each application instance runs in isolation, with its own work directory and process.

若要查看有哪些已命名应用和服务正在群集中运行,请运行 Get-ServiceFabricApplicationGet-ServiceFabricService cmdlet:To see which named apps and services are running in the cluster, run the Get-ServiceFabricApplication and Get-ServiceFabricService cmdlets:

PS C:\> Get-ServiceFabricApplication  

ApplicationName        : fabric:/MyApp
ApplicationTypeName    : MyApplicationType
ApplicationTypeVersion : 1.0.0
ApplicationStatus      : Ready
HealthState            : Ok
ApplicationParameters  : {}

PS C:\> Get-ServiceFabricApplication | Get-ServiceFabricService

ServiceName            : fabric:/MyApp/Stateless1
ServiceKind            : Stateless
ServiceTypeName        : Stateless1Type
IsServiceGroup         : False
ServiceManifestVersion : 1.0.0
ServiceStatus          : Active
HealthState            : Ok

删除应用程序Remove an application

当不再需要某个应用程序实例时,可以使用 Remove-ServiceFabricApplication cmdlet 按名称将其永久删除。When an application instance is no longer needed, you can permanently remove it by name using the Remove-ServiceFabricApplication cmdlet. Remove-ServiceFabricApplication 还将自动删除属于该应用程序的所有服务,永久删除所有服务状态。Remove-ServiceFabricApplication automatically removes all services that belong to the application as well, permanently removing all service state.

Warning

此操作无法撤消,并且无法恢复应用程序状态。

PS C:\> Remove-ServiceFabricApplication fabric:/MyApp

Confirm
Continue with this operation?
[Y] Yes  [N] No  [S] Suspend  [?] Help (default is "Y"):
Remove application instance succeeded

PS C:\> Get-ServiceFabricApplication

取消注册应用程序类型Unregister an application type

当不再需要某个特定版本的应用程序类型时,应使用 Unregister-ServiceFabricApplicationType cmdlet 取消注册该应用程序类型。When a particular version of an application type is no longer needed, you should unregister the application type using the Unregister-ServiceFabricApplicationType cmdlet. 取消注册未使用的应用程序类型时,会通过删除应用程序类型文件释放映像存储区使用的存储空间。Unregistering unused application types releases storage space used by the image store by removing the application type files. 如果使用了复制到映像存储区,取消注册应用程序类型不会删除复制到映像存储临时位置的应用程序包。Unregistering an application type does not remove the application package copied to the image store temporary location, if copy to the image store was used. 只要没有针对其实例化的应用程序或引用它的挂起应用程序升级,就可以注销应用程序类型。An application type can be unregistered as long as no applications are instantiated against it and no pending application upgrades are referencing it.

若要查看群集中当前已注册的应用程序类型,请运行 Get-ServiceFabricApplicationTypeRun Get-ServiceFabricApplicationType to see the application types currently registered in the cluster:

PS C:\> Get-ServiceFabricApplicationType

ApplicationTypeName    : MyApplicationType
ApplicationTypeVersion : 1.0.0
Status                 : Available
DefaultParameters      : { "Stateless1_InstanceCount" = "-1" }

运行 Unregister-ServiceFabricApplicationType 来取消注册特定的应用程序类型:Run Unregister-ServiceFabricApplicationType to unregister a specific application type:

PS C:\> Unregister-ServiceFabricApplicationType MyApplicationType 1.0.0

故障排除Troubleshooting

Copy-ServiceFabricApplicationPackage 请求 ImageStoreConnectionStringCopy-ServiceFabricApplicationPackage asks for an ImageStoreConnectionString

Service Fabric SDK 环境应已默认设置正确。The Service Fabric SDK environment should already have the correct defaults set up. 若有需要,所有命令的 ImageStoreConnectionString 都应匹配 Service Fabric 群集正在使用的值。But if needed, the ImageStoreConnectionString for all commands should match the value that the Service Fabric cluster is using. 可以在使用 Get-ServiceFabricClusterManifest 和 Get-ImageStoreConnectionStringFromClusterManifest 命令检索到的群集清单中找到 ImageStoreConnectionString:You can find the ImageStoreConnectionString in the cluster manifest, retrieved using the Get-ServiceFabricClusterManifest and Get-ImageStoreConnectionStringFromClusterManifest commands:

PS C:\> Get-ImageStoreConnectionStringFromClusterManifest(Get-ServiceFabricClusterManifest)

Service Fabric SDK PowerShell 模块中包含的 Get-ImageStoreConnectionStringFromClusterManifest cmdlet,用于获取映像存储连接字符串。The Get-ImageStoreConnectionStringFromClusterManifest cmdlet, which is part of the Service Fabric SDK PowerShell module, is used to get the image store connection string. 要导入 SDK 模块,请运行:To import the SDK module, run:

Import-Module "$ENV:ProgramFiles\Microsoft SDKs\Service Fabric\Tools\PSModule\ServiceFabricSDK\ServiceFabricSDK.psm1"

ImageStoreConnectionString 可在群集清单中找到:The ImageStoreConnectionString is found in the cluster manifest:

<ClusterManifest xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Name="Server-Default-SingleNode" Version="1.0" xmlns="http://schemas.microsoft.com/2011/01/fabric">

    [...]

    <Section Name="Management">
      <Parameter Name="ImageStoreConnectionString" Value="file:D:\ServiceFabric\Data\ImageStore" />
    </Section>

    [...]

有关映像存储和映像存储连接字符串的补充信息,请参阅了解映像存储连接字符串See Understand the image store connection string for supplementary information about the image store and image store connection string.

部署大型应用程序包Deploy large application package

问题:大型应用程序包(GB 级别)的 Copy-ServiceFabricApplicationPackage 超时。Issue: Copy-ServiceFabricApplicationPackage times out for a large application package (order of GB). 请尝试:Try:

  • 通过 TimeoutSec 参数为 Copy-ServiceFabricApplicationPackage 命令指定更长的超时。Specify a larger timeout for Copy-ServiceFabricApplicationPackage command, with TimeoutSec parameter. 此超时默认为 30 分钟。By default, the timeout is 30 minutes.
  • 检查源计算机和群集之间的网络连接。Check the network connection between your source machine and cluster. 如果连接缓慢,请考虑使用一台网络连接状况更好的计算机。If the connection is slow, consider using a machine with a better network connection. 如果客户端计算机位于另一个区域,而不在此群集中,请考虑使用此群集的邻近区域或同区域中的客户端计算机。If the client machine is in another region than the cluster, consider using a client machine in a closer or same region as the cluster.
  • 检查是否已达到外部限制。Check if you are hitting external throttling. 例如,将映像存储区配置为使用 Azure 存储时,可能会限制上传。For example, when the image store is configured to use azure storage, upload may be throttled.

问题:已成功完成上传包,但 Register-ServiceFabricApplicationType 超时。请尝试:Issue: Upload package completed successfully, but Register-ServiceFabricApplicationType times out. Try:

  • 复制到映像存储之前对包进行压缩Compress the package before copying to the image store. 压缩可减小文件大小,减少文件数量,这反过来会减少通信流量和 Service Fabric 必须执行的工作量。The compression reduces the size and the number of files, which in turn reduces the amount of traffic and work that Service Fabric must perform. 上传操作可能会变慢(尤其是包括压缩时间时),但注册和注销应用程序类型会加快。The upload operation may be slower (especially if you include the compression time), but register and un-register the application type are faster.
  • 通过 TimeoutSec 参数为 Register-ServiceFabricApplicationType 指定更长的超时。Specify a larger timeout for Register-ServiceFabricApplicationType with TimeoutSec parameter.
  • Register-ServiceFabricApplicationType 指定 Async 开关。Specify Async switch for Register-ServiceFabricApplicationType. 当群集接受命令并且应用程序类型的注册以异步方式继续时,该命令将返回。The command returns when the cluster accepts the command and the registration of the application type continues asynchronously. 因此,在此情况下,无需指定较长的超时。For this reason, there is no need to specify a higher timeout in this case. Get-ServiceFabricApplicationType 命令列出已成功注册的所有应用程序类型版本及其注册状态。The Get-ServiceFabricApplicationType command lists all successfully registered application type versions and their registration status. 此命令可用于确定注册的完成时间。You can use this command to determine when the registration is done.
PS C:\> Get-ServiceFabricApplicationType

ApplicationTypeName    : MyApplicationType
ApplicationTypeVersion : 1.0.0
Status                 : Available
DefaultParameters      : { "Stateless1_InstanceCount" = "-1" }

部署包含多个文件的应用程序包Deploy application package with many files

问题:具有多个文件(上千个)的应用程序包的 Register-ServiceFabricApplicationType 超时。Issue: Register-ServiceFabricApplicationType times out for an application package with many files (order of thousands). 请尝试:Try:

PS C:\> Get-ServiceFabricApplicationType

ApplicationTypeName    : MyApplicationType
ApplicationTypeVersion : 1.0.0
Status                 : Available
DefaultParameters      : { "Stateless1_InstanceCount" = "-1" }

后续步骤Next steps

打包应用程序Package an application

Service Fabric 应用程序升级Service Fabric application upgrade

Service Fabric 运行状况简介Service Fabric health introduction

对 Service Fabric 进行诊断和故障排除Diagnose and troubleshoot a Service Fabric service

在 Service Fabric 中对应用程序建模Model an application in Service Fabric