Mar*_*tin 2 azure azure-table-storage
我想从Azure网站(而不是Cloud Service)使用Azure表存储服务.有关如何使用Node.js执行此操作的指南,但我喜欢使用.NET MVC.
.NET的所有指南都讨论了如何将Azure存储连接信息存储在ServiceConfiguration中(就像在Cloud Service中一样),但在Azure网站中我没有这个(只是一个Web.config).如果我没有弄错的话,也不可能使用RoleEnvironment(用于从ServiceConfiguration读取)而不在Azure模拟器中运行,我不在AzureWeb站点中执行此操作.
是否可以从Azure网站访问表存储,如果可以,如何连接到它?
我看过这个问题,看起来并不相似.
您只需从web.config获取连接字符串并解析它(请注意,您也可以使用该CloudConfigurationManager.GetSetting方法):
var connectionString = ConfigurationManager.AppSettings["myStorageAccountConnectionString"];
var storageAccount = CloudStorageAccount.Parse(connectionString);
var tableClient = storageAccount.CreateCloudTableClient();
Run Code Online (Sandbox Code Playgroud)
在您的web.config中,您需要添加如下连接字符串:
<appSettings>
<add key="myStorageAccountConnectionString" value="DefaultEndpointsProtocol=https;AccountName=myaccount;AccountKey=fazfazefazefzeefazeefazfazefazef"/>
</appSettings>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
931 次 |
| 最近记录: |