question

RomainM-5255 avatar image
0 Votes"
RomainM-5255 asked KalyanChanumolu-MSFT rolled back

Remove extension from blob objects

Hi,

I have files named [number].json in my blob storage. I would like those files to be accessible without the extension in the URL.
For example, today a file can be accessed with the URL: https:/customDomainName/BlobStorageName/4.json
I would this same file to be accessible (only) using the URL: https:/customDomainName/BlobStorageName/4

I've tried using the CDN rules engine but didn't understand how it works.

Thank you for your help.
Best,
Romain

azure-blob-storage
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@RomainM-5255 Welcome to Microsoft Q&A forums.

An easy way would be to rename the blobs and remove the .json extension.

You can do that using Azure Storage Explorer or if you have a lot of files, you can use the SDK.
Please refer to this thread on StackOverflow for code samples

Does that work with you or do you need to retain the extension?

0 Votes 0 ·

Hi Kalyan, thank you for the answer!

I'd prefer to keep the extension. If I remove it, the browser will download the file instead of displaying the JSON directly in the page.
Is there a way to do this using Azure Blobs?

Best,
Romain

0 Votes 0 ·

1 Answer

KalyanChanumolu-MSFT avatar image
0 Votes"
KalyanChanumolu-MSFT answered KalyanChanumolu-MSFT edited

@RomainM-5255 Thank you for the additional context.
You should be able to set up URL rewrite on the CDN to route requests to BlobStorageName to automatically append a .json extension.

I have a created a sample regex here. Please test it, modify according to your use case and use it to configure the URL rewrite.

123493-image.png

The URL https://customDomainName/BlobStorageName/4 should rewrite the path to https://customDomainName/BlobStorageName/4.json


If an answer is helpful, please "Accept answer" or "Up-Vote" which might help other community members reading this thread.
And if you have further questions or issues, please let us know.


image.png (27.1 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.