DNX(asp.net 5)控制台应用程序作为Azure的网络招聘连接字符串配置未找到 [英] Dnx (asp.net 5) Console app as Azure Web Job connection strings configuration not found

查看:231
本文介绍了DNX(asp.net 5)控制台应用程序作为Azure的网络招聘连接字符串配置未找到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在所有关于如何得到蔚蓝网上工作,据说有两个变量AzureWebJobsDashboard,AzureWebJobsStorage在连接字符串存储连接手册。它工作正常普通的.NET,但它与DNX相当的一个问题,因为它似乎ConfigurationManager中不可有。所以,我已经添加了两个字符串在门户中的ConnectionStrings,但我不能找到一个很好的方式,网络招聘将如何自动读取它们。我结束了从环境变量读他们自己是这样的:

In all of the manuals about how to get the Storage connection for azure web jobs it is said to have those two variables AzureWebJobsDashboard, AzureWebJobsStorage in the connection strings. It works properly for ordinary .net, but it's quite an issue with DNX, since it seems that ConfigurationManager is not available there. So I have added the two strings to the ConnectionStrings in the portal, but I cannot find a good way how the Web Job would read them automatically. I ended up reading them myself from the Environment variables this way:

string dahsboard = Environment.GetEnvironmentVariable("CUSTOMCONNSTR_AzureWebJobsDashboard");
string storage = Environment.GetEnvironmentVariable("CUSTOMCONNSTR_AzureWebJobsStorage");

var configuration = new JobHostConfiguration();
configuration.DashboardConnectionString = dahsboard;
configuration.StorageConnectionString = storage;

JobHost host = new JobHost(configuration);
host.RunAndBlock();

但是,这是目前唯一的办法还是有一些方法,可以让网络招聘找到它自己的这一设置,如普通的.Net会?

But is this the only way now or there is some way that will let Web Job find this settings on it's own like ordinary .Net will?

推荐答案

您最好最好是将其设置为一个应用程序设置,而不是在Azure的门户网站的连接字符串。这样,您将能够通过简单的名称(如 AzureWebJobsDashboard ),没有搞笑的preFIX来引用它。一般来说,你应该避免在prefixes像 CUSTOMCONNSTR _ 建筑假设。

Your best best is to set it as an App Setting instead of a connection string in the Azure Portal. This way, you will be able to refer to it by simple name (e.g. AzureWebJobsDashboard) with no funny prefix. Generally, you should avoid building assumptions on prefixes like CUSTOMCONNSTR_.

这篇关于DNX(asp.net 5)控制台应用程序作为Azure的网络招聘连接字符串配置未找到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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