连接到azure存储帐户时出现404错误

twa*_*ron 3 .net azure-storage

我将通过Azure存储教程中的Azure存储帐户查看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);
        }
Run Code Online (Sandbox Code Playgroud)

和连接字符串

<appSettings>
    <add key="StorageConnectionString" value="DefaultEndpointsProtocol=https;AccountName=myAccount;AccountKey=mykey" />
</appSettings>
Run Code Online (Sandbox Code Playgroud)

有什么想法吗?我需要在Azure中做更多的事情吗?

twa*_*ron 5

问题是容器未创建或已被删除.我补充道

container.CreateIfNotExist();
Run Code Online (Sandbox Code Playgroud)

它工作得很好.我会期待一个不同的错误而不是404.但是修复了它.