我正在浏览此处找到的带有天蓝色存储帐户的 blob 教程Azure 存储教程 http://www.windowsazure.com/en-us/develop/net/how-to-guides/blob-storage/#upload-blob
我已经在 azure 上创建了存储帐户,它说它已启动。
我已将密钥和帐户名复制到我的配置文件中。
我已验证应用程序中的端点地址与我的 azure 存储帐户上的端点地址相匹配。
但当我运行代码时,出现 404 错误。
当我将端点地址从我的 Azure 帐户复制并粘贴到浏览器中时,我也收到 404 错误
这是我的代码。实际上是从教程中复制的,我确实将正确的帐户名和密钥添加到配置字符串中,但在这篇文章中删除了它们
// Retrieve storage account from connection string.
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
CloudConfigurationManager.GetSetting("StorageConnectionString"));
// Create the blob client.
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
// Retrieve reference to a previously created container.
CloudBlobContainer container = blobClient.GetContainerReference("mycontainer");
// Retrieve reference to a blob named "myblob".
CloudBlockBlob blockBlob = container.GetBlockBlobReference("myblob");
// Create or overwrite the "myblob" blob with contents from a local file.
using (var fileStream = System.IO.File.OpenRead(@"myfile"))
{
blockBlob.UploadFromStream(fileStream);
}
和连接字符串
<appSettings>
<add key="StorageConnectionString" value="DefaultEndpointsProtocol=https;AccountName=myAccount;AccountKey=mykey" />
</appSettings>
有什么想法吗?我需要在 Azure 中做更多事情吗?
问题是容器未创建或已被删除。我添加了
container.CreateIfNotExist();
效果很好。我本来期望出现一个不同的错误,而不是 404。但这解决了它。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)