Azure Storage Account Connection String

To get the connection string for an Azure Storage Account, follow these steps:

  1. Sign in to the Azure portal.

  2. Navigate to your storage account stffulaia47oona.

  3. In the left-hand menu section, under Settings, click on Access keys.

  4. Here, you can see key1 and key2 along with the connection strings. You can use either of them in your application.

  5. Click on the Show keys button and then copy the Connection string from either key1 or key2.

Now, to connect to the Blob storage and upload a file in C#, you can use the Azure.Storage.Blobs package. Here is a sample code snippet:

using Azure.Storage.Blobs;
using System.IO;

string connectionString = "<your-connection-string>"; // replace with your connection string
string containerName = "content";
string blobName = "<blob-name>"; // replace with your blob name
string filePath = "<file-path>"; // replace with your file path

// Get a reference to a container named "content" and then create it
BlobContainerClient container = new BlobContainerClient(connectionString, containerName);
container.CreateIfNotExists();

// Get a reference to a blob
BlobClient blob = container.GetBlobClient(blobName);

// Open the file and upload its data
using FileStream uploadFileStream = File.OpenRead(filePath);
blob.Upload(uploadFileStream, true);
uploadFileStream.Close();

Replace with the connection string you copied from the Azure portal, with the name you want for your blob, and with the path to the file you want to upload.

Remember to install the Azure.Storage.Blobs package. You can install it via NuGet package manager in Visual Studio or use the .NET CLI command: dotnet add package Azure.Storage.Blobs.

Last updated