2010-05-27 95 views
1

以下代碼在「CreateIfNotExist」方法調用中引發錯誤。我試圖連接到我的Azure的Blob存儲,並創建一個名爲新集裝箱「圖像」無法在Azure Blob存儲上創建Blob容器

var storageAccount = new CloudStorageAccount(
    new StorageCredentialsAccountAndKey("my_account_name", "my shared key"), 
    "https://blob.core.windows.net/", 
    "https://queue.core.windows.net/", 
    "https://table.core.windows.net/" 
); 
var blobClient = storageAccount.CreateCloudBlobClient(); 
var blobContainer = blobClient.GetContainerReference("images"); 
blobContainer.CreateIfNotExist(); 

的錯誤是:

[StorageClientException: The requested URI does not represent any resource on the server.] 

「影像」容器不存在,但我期待它被創建而不是被拋出的錯誤。我究竟做錯了什麼?

我試過HTTP而不是HTTPS,但結果是相同的錯誤。

回答

3

我已經想通了,我必須使用不同的語法

var storageAccount = new CloudStorageAccount(
    new StorageCredentialsAccountAndKey("my_account_name", "my shared key")); 
var blobClient = storageAccount.CreateCloudBlobClient(); 
var blobContainer = blobClient.GetContainerReference("images"); 
blobContainer.CreateIfNotExists(); 

通知結束點是如何被遺漏。顯然,CloudBlobClient可以自動計算出合適的URI。

0

確定帳戶名稱和共享密鑰正確嗎?您可以嘗試安裝Fiddler來查看HTTP流量以確保沒有任何可疑內容。