Where & how does one instantiate ServiceInitializationParameters in an Azure Service Fabric service?

为君一笑 提交于 2019-12-10 17:07:14

问题


Trying to use custom application configuration in my service. This post gives part of the answer, but it doesn't explain how & where you initialize the ServiceInitializationParameters object, which is required to get it working. The object does not seem to have a constructor. Documentation from Microsoft is sketchy and the provided sample on GitHub does not seem to use any custom app config.


回答1:


This post is based on the preview SDK. In the release version (2.0+) of the SDK, ServiceInitializationParameters was replaced with ServiceContext and its derived stateless and stateful versions. Check out the release notes for a comprehensive list of all the changes from preview to release.

Everything else in this post is still accurate, but you access the config stuff like this now:

 var configurationPackage = this.Context.CodePackageActivationContext.GetConfigurationPackageObject("Config");

 var connectionStringParameter = configurationPackage.Settings.Sections["UserDatabase"].Parameters["UserDatabaseConnectionString"];


来源:https://stackoverflow.com/questions/36786078/where-how-does-one-instantiate-serviceinitializationparameters-in-an-azure-ser

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!