对于ASP.NET MVC的Windows Azure存储模拟器连接字符串? [英] Windows Azure Storage Emulator Connection String for ASP.NET MVC?

查看:175
本文介绍了对于ASP.NET MVC的Windows Azure存储模拟器连接字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找这是需要被定义为使用的Windows Azure存储模拟器的连接字符串。

I am searching for the connection string that is need to be defined to use windows azure storage emulator.

到目前为止,我已经找到了来源说,这些连接字符串应该去位于 ServiceDefinition ServiceConfiguration 文件在Windows Azure项目。不过,我没有使用Azure项目,但ASP.NET MVC 3。

So far, all the sources I have found says these connection strings should go to ServiceDefinition and ServiceConfiguration files located in Windows Azure project. However, I am not using Azure project but the ASP.NET MVC 3.

有关,ASP.NET MVC项目时,它也许应该去的web.config 文件。但是,我不知道它应该是什么样子?

For, ASP.NET MVC project, it should probably go to web.config file. However, I have no idea what it should look like ?

我的Azure帐户,如果所需要的仿真器。

I have Azure account if that is needed for emulator.

感谢。

推荐答案

由于此的文章说ConnectionString的是 DevelopmentStorage = TRUE

As this article says connectionstring is DevelopmentStorage=true

所以在Web.config中你可以使用:

So in Web.config you can use:

  <appSettings>
    <add key="StorageConnectionString" value="UseDevelopmentStorage=true" />
 </appSettings>

在ServiceConfiguration.cscfg:

In ServiceConfiguration.cscfg:

  <Setting name="StorageConnectionString" value="UseDevelopmentStorage=true" />

您可以使用CloudConfigurationManager它将从服务Configratuon设置获取配置,如果它的存在。用它喜欢这样的:

You can use CloudConfigurationManager it will get the configuration from the Service Configratuon settings if it exists. Use it likes this:

CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
    CloudConfigurationManager.GetSetting("StorageConnectionString"));

如果它不存在ServiceConfiguration将回落到你的web.config的应用程序设置。这样,如果你移动应用程序到Azure,如果你想,而不必改变你如何找回您的连接字符串什么。我倾向于隐瞒这一切在ISettingsProvider接口(所以我不拿任何东西的依赖),但可能是矫枉过正。

If it doesn't exist in ServiceConfiguration it will fall back to the application settings of your web.config. That way if you move application to Azure if you want and not have to change anything in how you retrieve your connection strings. I tend to hide it all in an ISettingsProvider interface (So I don't take a dependency on anything) but that is probably overkill.

将在ServiceConfiguration连接的主要好处是,你可以更改设置,而无需重新部署应用程序。

The main benefit of putting connection in the ServiceConfiguration is that you can change the setting without having to re-deploy the application.

如果您选择使用的web.config那么你可以使用转换到developmentstorage帐户交换到上发布真实账户。如果您使用Azure的只是在云服务配置不同的连接字符串。

If you choose to use web.config then you can use transform to swap out the developmentstorage account to a real account on publish. If you use Azure just have a different connection string in the Cloud service configuration.

不需要实际的Azure帐户来运行模拟器。

Don't need actual Azure account to run the emulator.

这篇关于对于ASP.NET MVC的Windows Azure存储模拟器连接字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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