Kris
Kris

Reputation: 880

Can azure table storage be accessed from Web applications hosted on IIS

I have a web application that is hosted on IIS. I do not want to create it as a Web role. Can I still access azure table storage from web application that is hosted on IIS?

Upvotes: 2

Views: 347

Answers (1)

Pascal
Pascal

Reputation: 1141

Yes you can. Just grab the Windows Azure Storage package on NuGet and then do something like this:

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);

Then do what ever you need to do. You can replace the "UseDevelopmentStorage=true" with a proper connection string like "DefaultEndpointsProtocol=http;AccountName=...;AccountKey=...". You will need to use upload a certificate to use a https connection.

Just know that you will be billed for all the data going out of the Azure data center. I would not recommend using Azure Storage as the primary data storage solution for you website if you have a lot of traffic. It would definitely better to host your application in a web role or an Azure Web Site.

Upvotes: 2

Related Questions