Create Azure Table Storage using console Application
Create a C# Console Application using Visual Studio
Install Below DLL Using Nuget Package
- WindowsAzure.Storage
- Microsoft.WindowsAzure.ConfigurationManager
Inside of your Console app, you will see App.config, now add the following section:
<appSettings>
<add key="StorageConnection" value="YOUR-CONNECTION-STRING-COPIED-FROM-EARLIER"/>
</appSettings>
Copy the following code into your Main method:
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
CloudConfigurationManager.GetSetting("StorageConnection"));
CloudTableClient tableClient = storageAccount.CreateCloudTableClient();
// Name of table to be create
CloudTable table = tableClient.GetTableReference("AzureDemo");
table.CreateIfNotExists();
Console.ReadKey();
Run the Project
This code will get our connection string from the App.config, create our client and a table named AzureDemo if it doesn't exist. We can go back inside of the portal to see if executed correctly.
Comments
Post a Comment