简体   繁体   中英

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

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.

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"];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM