凡与放大器;一个人如何实例ServiceInitializationParameters在Azure的服务织物服务吗? [英] Where & how does one instantiate ServiceInitializationParameters in an Azure Service Fabric service?

查看:225
本文介绍了凡与放大器;一个人如何实例ServiceInitializationParameters在Azure的服务织物服务吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试使用自定义应用程序的配置在我的服务。 这篇文章给出了答案的一部分,但它并没有解释如何与放大器;在那里你初始化的 ServiceInitializationParameters 的对象,这是需要得到它的工作。对象似乎并不有一个构造函数。从微软文档是粗略的和的在GitHub上提供的样本似乎并没有使用任何自定义应用程序的配置。

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.

推荐答案

这个帖子是基于预览版SDK。在的发行版本(2.0+)的SDK,ServiceInitializationParameters用的 ServiceContext 及其派生的无国籍和的状态版本。查看发行说明从所有变化的完整列表预览发布。

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

这篇关于凡与放大器;一个人如何实例ServiceInitializationParameters在Azure的服务织物服务吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆