在vs2022新增完一個C# Console專案後

到nuget安裝套件
Azure.Storage.Blobs


這裡透過cli創建一個Azure Storage Account
az storage account create -n sastg1 -g NetworkWatcherRG -l westus --sku Standard_LRS
這邊可能會因為名稱已經被採用重複try好幾次
建議取比較不是單字的簡寫

透過cli來創建container
az storage container create --account-name sastg1 --name scstg1

回到資源portal中查閱就可看到cli產物



C#這裡可以到Storage Account的Access Key
複製連接字串
然後再指定要創建的container name (這邊指定 scstg2)
using Azure.Storage.Blobs;
Console.WriteLine("Begin Create Azure Storage Container");
string connectionStr = "{你的StorageAccount連接字串}";
string containerName = "{要新建的Containr名稱}";
BlobServiceClient blobServiceClient = new BlobServiceClient(connectionStr);
await blobServiceClient.CreateBlobContainerAsync(containerName);
Console.WriteLine("Create Azure Storage Container Succes");

