【发布时间】:2013-03-31 11:33:47
【问题描述】:
我有一个托管在 IIS 上的 Web 应用程序。我不想将其创建为 Web 角色。我仍然可以从 IIS 上托管的 Web 应用程序访问 Azure 表存储吗?
【问题讨论】:
标签: azure-storage
我有一个托管在 IIS 上的 Web 应用程序。我不想将其创建为 Web 角色。我仍然可以从 IIS 上托管的 Web 应用程序访问 Azure 表存储吗?
【问题讨论】:
标签: azure-storage
是的,你可以。只需在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 网站托管您的应用程序肯定会更好。
【讨论】: