是否可以从IIS上托管的Web应用程序访问azure表存储

时间:2013-04-09 06:49:33

标签: azure-storage

我有一个托管在IIS上的Web应用程序。我不想将其创建为Web角色。我还可以从IIS上托管的Web应用程序访问azure表存储吗?

1 个答案:

答案 0 :(得分:2)

是的,你可以。只需抓取NuGet上的Windows Azure存储包,然后执行以下操作:

CloudStorageAccount storageAccount = CloudStorageAccount.Parse("UseDevelopmentStorage=true");

// Create the table client
CloudTableClient tableClient = storageAccount.CreateCloudTableClient();

// Create the table if it doesn't exist
string tableName = "people";
tableClient.CreateTableIfNotExist(tableName);

然后做你需要做的事。您可以使用正确的连接字符串替换“UseDevelopmentStorage = true”,例如“DefaultEndpointsProtocol = http; AccountName = ...; AccountKey = ...”。您需要使用上传证书才能使用https连接。

只需知道您将收到从Azure数据中心发出的所有数据的费用。如果您有大量流量,我建议不要将Azure存储用作您网站的主要数据存储解决方案。将您的应用程序托管在Web角色或Azure网站中肯定会更好。