AZ 104 Microsoft Azure Administrator Day - 3 Bootcamp
Introduction Azure Tables
Azure Tables are structured, schema-less NoSQL data stores in the cloud. Tables are commonly used to store flexible datasets such as user data for a web application and other kinds of metadata.
In addition to Tables, Microsoft has other database offerings such as their premium NoSQL Cosmos DB as well as many others SQL and NoSQL solutions. The differences between Azure Tables and Azure Cosmos DB are outlined .
What is Azure Storage Tables?
They are a NoSQL key-value store for rapid development using massive semi-structured datasets
Azure Storage Tables as key-value data set that you can query vs. Azure Storage Blobs which are typically files.
#Getting Started
Go ahead and open the Azure Portal and click Create a Resource and select Azure Storage. We'll keep it simple as shown below to get started.
Once complete, go into the resource and look under Services.
Go ahead and click on Tables and you could create a new table through the portal as shown below.
If we did that, then we'd see a table along with the URL that it is accessible from.
While this is good and fine, we'd like to create the table dynamically to represent a real-world scenario.
For this example, we'll use C#.
While inside the blade for Azure Storage, look under Settings, then Access Keys and copy the connection string.
Create a C# Console Application using Visual Studio, and use NuGet to pull in references to :
- Azure.Data.Tables
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>
2
3
Copy the following code into your Main method:
static void Main(string[] args)
{
var serviceClient = new TableServiceClient(ConfigurationManager.AppSettings["StorageConnection"]);
TableClient table = serviceClient.GetTableClient("thankfulfor");
table.CreateIfNotExists();
Console.ReadKey();
}
2
3
4
5
6
7
8
This code will get our connection string from the App.config, create our client and a table named thankfulfor if it doesn't exist. We can go back inside of the portal to see if executed correctly.
Comments
Post a Comment