CDN with Storage Account - azure

I create the the Storage account, CDN Profile and CDN endpoint from powershell. But adding images to the storage account is a manual process after creating all azure components. Now we have the issue that images are not showing up in page. When I try to access the CDN image url directly, I get this error
The requested URI does not represent any resource on the server
But I can access the content directly by using blob storage url to ensure content exist. I tried changing the caching rules , but nothing is working. I have standard verizon cdn profile.
Any suggestions?
Update1 : When I delete the endpoint and recreate the endpoint with all images already loaded in Storage account, everything works fine. Any idea what is the predictable behaviour?

This error happens when you're using a "/" with the root container where the blob is present (sub-folders). for now the "/" are not supported, you can get around it by referencing the root container in the link, ex:
GET https://myaccount.blob.core.windows.net/$root/myphoto
When using the CDN, the format should look like the following:
http://<EndpointName>.azureedge.net/<myPublicContainer>/<BlobName>
There is also a cool tutorial on how to host static sites via blobs and CDN worth checking out: https://blog.lifeishao.com/2017/05/24/serving-your-static-sites-with-azure-blob-and-cdn
Documentation:
You can get more info from these links: https://learn.microsoft.com/en-us/rest/api/storageservices/Working-with-the-Root-Container?redirectedfrom=MSDN
https://learn.microsoft.com/en-us/azure/cdn/cdn-create-a-storage-account-with-cdn

Related

Can't access images via web with Azure storage and Django

I want to access the path of the image/blog in the browser, I am using Django rest API and the package Azure storage, I tried to make the container storage public, but still had no luck in accessing the image, what could be wrong?
This is an example of the image I want to access, it's there in the storage but can't access it :
https://guiomentor-staging.azurewebsites.net/media/blog_images/images_3.jpeg
If you store your images in a container of a storage account and grant public to the container then you can access the images using a URL.
First create a container under the Containers tab in the storage and then set the access level to container .
Now click on the newly created container and then click on upload and upload images in the container .
Here I have uploaded two images If you click on the images a pop will immerge with the url of the that image
This url is publicly accessible and you can make get request to it in you django app
In Browser :
In Postman :
you don't even need to go the storage account for url
the urls will be of format :
https://<Storage Acount Name>.blob.core.windows.net/<Container>/<Image Name>
#Siddhartha Vikram answer is also correct using the azure storage.blob

"WebContentNotFound" error with azure static web

I have made a storage account then enabled static website then added the html file (plus everything else i need). once everything was added into the $web i copy pasted the give url and i get a 404 error as follows:
The requested content does not exist.
HttpStatusCode: 404
ErrorCode: WebContentNotFound
RequestId : 23ac6dc2-401e-0044-7797-b2e9c5000000
TimeStamp : 2021-09-26T05:29:47.2306494Z
i have used azure before for another school project and that website worked fine. i tried uploading those files in a new storage account and they gave me the same error but the website i made 6 months ago still works. naturally i thought well if this storage account still works then i will just put the new files in here and delete this website since its not needed anymore. tried and it gave me the same error so i changed it back to the original and now i get the error with those files too. any help would be amazing.
Azure blob storage doesn’t know to route requests to /OurWebPage through our index.html it only knows to route to index.html when requests are made to the base URL as we configured the default document. This means search crawlers and anyone linking directly to a page will get this error
Here we need to use Azure CDN, with this we can configure URL rewrites.
We can create CDN resource with Standard Microsoft tier. Refer to the blog for more insights.

Azure CDN to Azure storage gives BlobNotFound, direct link to storage shows the image

I am following a pluralsight course to get familiar with more aspects of Azure. CDN is one of the aspects yet I fail to get it work and I can't figure out what I am doing wrong.
The pluralsight course I am following is called Building a Global App with Azure PaaS. The steps to create an Azure storage and a CDN are explained pretty clear, yet the CDN won't work for me. I did those steps twice. I also followed the steps described on this page: Getting started with Azure CDN but gives me the same result. These are my results:
1) The image is reachable via the following links:
link 1 to azure storage
link 2 to azure storage
2) I also try to reach the image via this link:
link to azureedge.net (CDN)
but this link gives me this error:
<Error>
<Code>BlobNotFound</Code>
<Message>
The specified blob does not exist. RequestId:162b11b9-0001-0010-5713-ce53d6000000 Time:2017-05-16T07:08:30.2920262Z
</Message>
</Error>
The error code states that the blob does not exists, but I found that description to be unclear because the link 1 and link 2 are working fine, so where does the blob not exists?
I also waited more than 90 minutes (close to a day even) and checked if it worked after that period. The first try of creating the CDN I did before the start of the weekend and the next monday it still didn't work.
The azure storage access policy is set to container. According to the information on azure, this should make all the content of the container read-only available.
Has anyone any idea what I could do wrong?
I believe I know why this problem is happening. Because you have set the Origin Path to cdn, the URL http://testcdncornelis.azureedge.net maps to http://psic2.blob.core.windows.net/cdn and not http://psic2.blob.core.windows.net . Now you're appending cdn to this CDN path, the actual URL to blob storage becomes http://psic2.blob.core.windows.net/cdn/cdn/cookie.jpg. Since the blob is present in cdn container and not in cdn virtual folder inside cdn container, you're getting this error.
There are 2 ways by which you can fix this problem:
Remove Origin Path setting in your CDN configuration. Then testcdncornelis.azureedge.net will map to psic2.blob.core.windows.net and you can use the URL you're using right now.
Keep Origin Path but change the CDN URL you're using to http://testcdncornelis.azureedge.net/cookie.jpg.
Please see Origin Path section in the troubleshooting guide here: https://learn.microsoft.com/en-us/azure/cdn/cdn-troubleshoot-endpoint.

Azure Functions Proxy - route to storage account

I could create an azure function proxy with success that routes requests to my blob storage. However, it only works if I specify the Backend URL with the full url to the blob file:
ex:
https://account.blob.core.windows.net/site/index.html
where '/site' is my container name and 'index.html' is my blob name.
I had an understanding that I could use the route template as '/site' and if I leave the Backend URL as 'https://account.blob.core.windows.net/site/' what comes after the last '/' would be routed to my storage account. Did I understand wrong?
UPDATE
After reading this other question Azure Function App Proxy to a blob storage account and update the route template / backend url it works, but if my blob name has an extension it does not work (such as .html). Any clues?
Yes we have identified a bug when URL ends with an .extension and will release the fix in the next few days. Thanks much for the feedback.
In the Azure Functions Proxy documentation they specify how to get the request parameters and pass those to your backend service.
Your template can be /site/{*restOfPath}
And your backend would be https://account.blob.core.windows.net/site/{restOfPath}
I was able to get this working only on files that do NOT have a file extension. So I was able to add an index blob and get to it from https://myfunction.azurewebsites.net/index, however, when I tried index.html, the proxy returned a message "The resource you are looking for has been removed, had its name changed, or is temporarily unavailable."

ACL access abilities for Azure Containers and Blobs

I am looking at using azure Containers and Blobs to store images and videos for my website. I found http://msdn.microsoft.com/en-us/library/windowsazure/dd179354.aspx which talks about the different ALC settings but it did not answer one of my questions. If a Container/Blob are set to "No public read access" the site says that only the account owner can read the data. Would this mean that people could not access it by the URL but my MVC Web App hosted on an Azure VM would be able to access it via URL?
Please bear with me if the answer sounds a bit preachy & unnecessary lengthy :)
Essentially each resource (Blob Container, Blob) in Windows Azure has a unique URL and is accessible via REST API (thus accessible over http/https protocol). Wit ACL, you basically tell storage service whether or not to honor the request sent to serve the resource. To read more about authentication mechanism, you may find this link useful: http://msdn.microsoft.com/en-us/library/windowsazure/dd179428.aspx.
When you set the ACL as No public read access, you're instructing storage service not to honor any anonymous requests. Only authenticated requests will be honored. To create an authenticated request, you would require your account name and key and create an authorization header which gets passed along with the request to access the request. If this authorization header is not present in your request, the request will be rejected.
So long story short, to answer your question even your MVC application won't be able to access the blob via URL unless that authorization header is included in the request. One possibility would be to explore Shared Access Signature (SAS) functionality in blob storage. This would give time-bound restricted permissions to blobs in your storage. So what you would do is create a SAS URL for your blob in your MVC app using your account name and key and use that SAS URL in the application.
To further explain the concept of ACL, let's say you have a blob container called mycontainer and it has a blob called myblob.txt in a storage account named myaccount. For listing blobs in the container, the container URL would be http://myaccount.blob.core.windows.net/mycontainer?restype=container&comp=list and the blob URL would be http://myaccount.blob.core.windows.net/mycontainer/myblob.txt. Following will be the behavior when you try to access these URLs directly through the browser with different ACL:
No public read access
Container URL - Error
Blob URL - Error
Public read access for blobs only
Container URL - Error
Blob URL - Success (will download the blob)
Full public read access
Container URL - Success (will show an XML document containing information about all blobs in the container)
Blob URL - Success (will download the blob)

Resources