I am trying to learn how to use blobs. With this code I want to upload my text file. I do not get errors. All that hapens is that the file is not found in the container. And I have read previous similar questions but none used this method.
What am I missing here?
using Azure.Storage.Blobs;
using System.IO;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
Upload_it_Async();
}
private static async void Upload_it_Async()
{
var filepath = @"C:\my_file.txt";
var connectionString = ***********;
var containerName = "my_container";
BlobServiceClient blobServiceClient = new BlobServiceClient(connectionString);
var container = blobServiceClient.GetBlobContainerClient(containerName);
var blockBlob = container.GetBlobClient("my_file.txt");
using (FileStream fs = File.Open(filepath, FileMode.Open))
{
await blockBlob.UploadAsync(fs);
}
}
}
}