"WebContentNotFound" error with azure static web - azure

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.

Related

Azure CDN: How to URL Rewrite for specific page

I have an Azure CDN profile resource with Premium Verizon tier which allows customization for Rule Engine
Created an endpoint which serves from a URL https://test-cdn1.azureedge.net the content from a storage account which is mapped as the origin to blob container in storage account with origin path pointing to blob container name /blob-container
I am trying to add Rewrite rules (in HTTP Large Object Rules Engine Section) for specific two pages
https://test-cdn1.azureedge.net/main.js URL should rewrite to https://test-cdn1.azureedge.net/js/main.d20ff936.chunk.js
This file is at /blob-container/js/main.d20ff936.chunk.js
https://test-cdn1.azureedge.net/main.css URL should rewrite to https://test-cdn1.azureedge.net/css/main.cb03e.chunk.css
This file is at /blob-container/css/main.cb03e.chunk.css
https://test-cdn1.azureedge.net/vendor.js URL should rewrite to https://test-cdn1.azureedge.net/js/js/1.77a25e9f.chunk.js
This file is at /blob-container/js/js/1.77a25e9f.chunk.js
Here is a screenshot of what I have added at hte momement and is not working.
Also for any other URL request, I wish to give back a plain old empty 404 - Not Found.
Need help, thanks
I know the problem now, solved it by a few tries, it does take some time to get effective though.
The source and destination entries are the mapped folder path to the resource, so in above the three entry would be
Source: blob-container/main.js, Destination: blob-container/js/main.d20ff936.chunk.js
Source: blob-container/main.css, Destination: blob-container/css/main.cb03e.chunk.css
Source: blob-container/vendor.js, Destination: blob-container/js/1.77a25e9f.chunk.js
Still look for a way to return 404 Not Found for all other CDN path URL fetches

CDN with Storage Account

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

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."

Azure website restore error

I am getting the following error when restoring a website backup (deployment slot). I am making the backup and trying to restore it using the azure management portal:
Failed to restore the Backup to App xxx(xxxstaging), Check your app
Custom HostNames, Databases and Connection strings. Restore operation
may fail if there are conflicts between source and destination
The audit log shows the following info:
statusCode:BadRequest serviceRequestId:
statusMessage:{"Code":"BadRequest","Message":"The provided URI is
not a SAS URL for a container (it needs to be https and it has to have
2 segments).","Target":null,"Details":[{"Message":"The provided URI
is not a SAS URL for a container (it needs to be https and it has to
have 2
segments)."},{"Code":"BadRequest"},{"ErrorEntity":{"Code":"BadRequest","Message":"The
provided URI is not a SAS URL for a container (it needs to be https
and it has to have 2
segments).","ExtendedCode":"54103","MessageTemplate":"The provided URI
is not a SAS URL for a container (it needs to be https and it has to
have 2
segments).","Parameters":[],"InnerErrors":null}}],"Innererror":null}
It is very strange because it was working in the past, and it happens in one deployment slot, nothing changes between the backup and the restore (same hostname, database and connection string, same storage account, same subscription...)
Any ideas?
perhaps it is due to some breaking changes introduced by Azure in the recent updates.
From your error description, it seems like the root cause of the problem is due to the provided URI is not a SAS URL for a container.
I suggest you to take a look at the Examples of SAS URLs from a very recent Microsoft blog post as below.
Examples of SAS URIs
Hope this helps.

Resources