Created
January 31, 2019 04:41
-
-
Save donma/27512913903fd82e11ac670bf6fe5bf4 to your computer and use it in GitHub Desktop.
Azure Blob Storage Create File in Directory
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var connsctionString = "your_connection_string"; | |
var cloudStorage = Microsoft.WindowsAzure.Storage.CloudStorageAccount.Parse(connsctionString); | |
//Check Contain is Existed. | |
var cloudBlobClient = cloudStorage.CreateCloudBlobClient(); | |
var cloudBlobContainer = cloudBlobClient.GetContainerReference("donmablogsample"); | |
var resultCreateContainer = cloudBlobContainer.CreateIfNotExistsAsync().Result; | |
//取得該檔案夾 TEST | |
Microsoft.WindowsAzure.Storage.Blob.CloudBlobDirectory cloudBlobDirectory = | |
cloudBlobContainer.GetDirectoryReference("TEST"); | |
//在該檔案夾下面建立檔案 | |
var bFileInfo = cloudBlobDirectory.GetBlockBlobReference("sampleText.json"); | |
bFileInfo.Properties.ContentType = "application/json; charset=utf-8"; | |
bFileInfo.UploadTextAsync("{\"data\":\"測試資料\"}").GetAwaiter().GetResult(); | |
Console.WriteLine("Success Update File TEST/sampleText.json"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment