了解 ImageStoreConnectionString 设置Understand the ImageStoreConnectionString setting

在某些文档中,浅要提及了“ImageStoreConnectionString”参数的存在,但未阐述其真正的含义。In some of our documentation, we briefly mention the existence of an "ImageStoreConnectionString" parameter without describing what it really means. 在阅读了使用 PowerShell 部署和删除应用程序之类的文章之后,你所要做的似乎就是复制/粘贴目标群集的群集清单中所示的值。And after going through an article like Deploy and remove applications using PowerShell, it looks like all you do is copy/paste the value as shown in the cluster manifest of the target cluster. 因此,每个群集的设置都必须是可配置的,但你通过 Azure 门户创建群集时,没有用于配置此设置的选项,它始终是“fabric:ImageStore”。So the setting must be configurable per cluster, but when you create a cluster through the Azure portal, there's no option to configure this setting and it's always "fabric:ImageStore". 那么,此设置有何用途?What's the purpose of this setting then?


Service Fabric 一开始被许多不同的团队用作 Azure 内部消耗平台,因此,其某些方面是高度可自定义的,“映像存储 (Image Store)”就是这样的存在。Service Fabric started off as a platform for internal Azure consumption by many diverse teams, so some aspects of it are highly customizable - the "Image Store" is one such aspect. 从根本上来说,映像存储区是用于存储应用程序包的可插入存储库。Essentially, the Image Store is a pluggable repository for storing application packages. 将应用程序部署到群集中的节点时,该节点将从映像存储区下载应用程序包的内容。When your application is deployed to a node in the cluster, that node downloads the contents of your application package from the Image Store. ImageStoreConnectionString 是一种设置,其中包括查找适合给定群集的映像存储区时所需的所有客户端和节点信息。The ImageStoreConnectionString is a setting that includes all the necessary information for both clients and nodes to find the correct Image Store for a given cluster.

目前有 3 种可能类型的映像存储区提供程序,其相应的连接字符串如下所示:There are currently three possible kinds of Image Store providers and their corresponding connection strings are as follows:

  1. 映像存储区服务:“fabric: ImageStore”Image Store Service: "fabric:ImageStore"

  2. 文件系统:“file:[file system path]”File System: "file:[file system path]"

  3. Azure 存储:“xstore:DefaultEndpointsProtocol=https;AccountName=[...];AccountKey=[...];Container=[...];EndpointSuffix=core.chinacloudapi.cn”Azure Storage: "xstore:DefaultEndpointsProtocol=https;AccountName=[...];AccountKey=[...];Container=[...];EndpointSuffix=core.chinacloudapi.cn"

生产中使用的提供程序类型是映像存储区服务,这是一种可从 Service Fabric Explorer 查看的状态持久化系统服务。The provider type used in production is the Image Store Service, which is a stateful persisted system service that you can see from Service Fabric Explorer.


通过在群集自身的系统服务中承载映像存储区,可消除程序包存储库的外部依赖关系,并可更大程度控制存储区域。Hosting the Image Store in a system service within the cluster itself eliminates external dependencies for the package repository and gives us more control over the locality of storage. 围绕映像存储区的后续改进很可能先针对映像存储区提供程序(若非唯一目标)。Future improvements around the Image Store are likely to target the Image Store provider first, if not exclusively. 由于客户端已连接到目标群集,因此映像存储区服务提供程序的连接字符串不具有任何唯一信息。The connection string for the Image Store Service provider doesn't have any unique information since the client is already connected to the target cluster. 客户端只需知道应使用哪些面向系统服务的协议。The client only needs to know that protocols targeting the system service should be used.

开发期间,为了略微加快群集的启动,将对本地单机群集使用文件系统提供程序,而不是映像存储区服务。The File System provider is used instead of the Image Store Service for local one-box clusters during development to bootstrap the cluster slightly faster. 区别通常很小,但对大多数人而言,这是开发期间的一项实用优化。The difference is typically small, but it's a useful optimization for most folks during development. 也可通过其他存储提供程序类型部署本地单机群集,但通常无需这样做,因为不管提供程序如何,开发/测试工作流都将保持不变。It's possible to deploy a local one-box cluster with the other storage provider types as well, but there's usually no reason to do so since the develop/test workflow remains the same regardless of provider. Azure 存储提供程序仅用于为在引入映像存储服务提供程序前部署的旧群集提供旧版支持。The Azure Storage provider only exists for legacy support of old clusters deployed before the Image Store Service provider was introduced.

此外,文件系统提供程序或 Azure 存储提供程序都不应用作在多个群集之间共享映像存储的方法 - 这会导致群集配置数据损坏,因为每个群集都可将冲突数据写入到映像存储。Furthermore, not the File System provider or the Azure Storage provider should be used as a method of sharing an Image Store between multiple clusters - this will result in corruption of cluster configuration data as each cluster can write conflicting data to the Image Store. 若要在多个群集之间共享预配的应用程序包,请改用 sfpkg 文件,可以使用下载 URI 将这些文件上传到任何外部存储。To share provisioned application packages between multiple clusters, use sfpkg files instead, which can be uploaded to any external store with a download URI.

因此虽然可配置 ImageStoreConnectionString,但只需使用默认设置。So while the ImageStoreConnectionString is configurable, you just use the default setting. 通过 Visual Studio 发布到 Azure 时,该参数会相应地自动设置。When publishing to Azure through Visual Studio, the parameter is automatically set for you accordingly. 对于 Azure 中托管的群集的编程部署,连接字符串始终为“fabric: ImageStore”。For programmatic deployment to clusters hosted in Azure, the connection string is always "fabric:ImageStore". 有疑问时,始终可通过 PowerShell.NETREST 检索群集清单验证其值。Though when in doubt, its value can always be verified by retrieving the cluster manifest by PowerShell, .NET, or REST. 同样,本地测试和生产群集应始终配置为使用映像存储区服务提供程序。Both on-premises test and production clusters should always be configured to use the Image Store Service provider as well.

后续步骤Next steps

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