다음을 통해 공유


Azure Troubleshooting: Error 404 ResourceNotFound Error After Uploading to Container

Introduction

Here, in this post, we are going to a see how we can resolve the error 404 ResourceNotFound Error After Uploading to Azure CDN. It is obvious that we may feel very sad if we are unable to see the image you recently uploaded to Azure container. But, we don’t need to worry about it, as the fix for this error is very simple and in this post, we are going to see that. Hope you will like this. Now let’s begin.

Background

Recently created a new container in Azure storage account and uploaded one image to it. And when opening that image in a browser, it was getting an error as proceeding.

This XML file does not appear to have any style information associated with it. The document tree is shown below.
<Error>
<Code>ResourceNotFound</Code>
<Message>
The specified resource does not exist. RequestId:36bdbcfb-0001-0022-44c6-d60b93000000 Time:2017-05-27T08:55:09.8382429Z
</Message>
</Error>

Was able to download that image and the problem exists only when we open it in the browser. Then we came to know about the Access Policy of Azure containers. Here we are going to see an introduction to that policy.

Solution for Azure 404 Error

Step 1: Login to the Azure Portal and navigate to the container.

Step 2: Now, click the three dots (…) and then Access Policy.

Step 3: Select the access type you prefer.

http://sibeeshpassion.com/wp-content/uploads/2017/05/Option-to-see-Azure-Container-Policy.png

Option to see Azure Container Policy

According to Microsoft, Access Policy specifies whether data in the container may be accessed publicly. By default, container data is private to the account owner. Use ‘Blob’ to allow public read access for blobs. Use ‘Container’ to allow public read and list access to the entire container.

Here we are going to give the policy as Blob.

http://sibeeshpassion.com/wp-content/uploads/2017/05/Change-the-Azure-Access-Policy-to-Blob.png

Change the Azure Access Policy to Blob

We can always do this with some C# code as well.

public static  void SetPublicContainerPermissions(CloudBlobContainer container)
{
    BlobContainerPermissions perm = container.GetPermissions();
    perm.PublicAccess = BlobContainerPublicAccessType.Blob;
    container.SetPermissions(perm);
}

In the above example, we are accessing the permissions and assigning the Blob access type. We can always use ‘Container’ if we want to limit access to the container. In any case, if we need to remove the permission to anonymous users, we can use BlobContainerPublicAccessType.Off. Once we are done, please reload the URL again the browser to be able to see our image. Happy Uploading!.

Conclusion

Miss anything that you may think which is needed? Could you find this post as useful? Hope you liked this article. Please share your valuable suggestions and feedback.