.net 连接到azure存储帐户时出现404错误
我正在阅读有关在此处找到的azure存储帐户的Blob的教程 我已经在azure上创建了存储帐户,它说它已启动。 我已将密钥和帐户名复制到配置文件中。 我已验证应用程序中的终结点地址与azure存储帐户上的地址匹配。 但是当我运行代码时,我得到一个404错误。 当我将azure帐户中的端点地址复制并通过浏览器时,也会出现404错误 这是代码。实际上是从教程中复制的,我确实在配置字符串中添加了正确的帐户名和密钥,但在本文中删除了它们.net 连接到azure存储帐户时出现404错误,.net,azure-storage,.net,Azure Storage,我正在阅读有关在此处找到的azure存储帐户的Blob的教程 我已经在azure上创建了存储帐户,它说它已启动。 我已将密钥和帐户名复制到配置文件中。 我已验证应用程序中的终结点地址与azure存储帐户上的地址匹配。 但是当我运行代码时,我得到一个404错误。 当我将azure帐户中的端点地址复制并通过浏览器时,也会出现404错误 这是代码。实际上是从教程中复制的,我确实在配置字符串中添加了正确的帐户名和密钥,但在本文中删除了它们 // Retrieve storage account
// 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。但这解决了问题