2016-10-25 5 views
0

私はAzureストレージを使い慣れていません。コンテナを作成したいだけでなく、blob(XMLファイルなど)も作成したいと考えています。ここではコンテナを作成するためのコードですが、XMLを作成する方法(ローカルにはフォームをアップロードしない)に問題があります。紺碧のストレージにXMLファイルを作成するには?

// Retrieve storage account from connection string. 
     CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
      CloudConfigurationManager.GetSetting("StorageConnectionString")); 

     // Create the blob client. 
     CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient(); 

     // Retrieve a reference to a container. 
     CloudBlobContainer container = blobClient.GetContainerReference("XXXXXXXX"); 

     // Create the container if it doesn't already exist. 
     container.CreateIfNotExists(); 

誰かがいくつかのコード例を提供することができます素晴らしいです!

ありがとうございます!

答えて

0

あなたがコンテナの参照を取得するには、上記のコードで終了したら、以下の操作を行います。

//Create reference to a Blob that May or Maynot exist under the container 
CloudBlockBlob blockBlob = container.GetBlockBlobReference("something.xml"); 
// Create or overwrite the "something.xml" blob with contents from a string 

      string s = "your XML"; 
      await blockBlob.UploadTextAsync(s); 
+1

は非常に良いありがとうございます! –

+0

また、blob.CreateIfNotExists();のようなXMLを作成する必要がありますか? –

+0

本当にありません。上記のコードを使用して、MVCのコントローラから新しいHTMLファイルを作成します。私はそのようなblob.CreateIfNotExists()を認識していません – JOW

関連する問題