How to access an object in Microsoft Azure Storage Service publicly? - azure

I would like to upload some images to be stored in Azure, I discovered that there is called 'Storage' in Blob, after doing some research I was able create my account in storage service and I'm accessing it with 'Azure Storage Explorer'.
1)There's another software that I could access my storage account ? Or another way to do it ?
2)What's the difference between 'public container' and 'public blob'?
3)I would like to create sub-folders, how can I do that ?
4)How can I make an image that I upload to the 'public blog' called 'image', been like this image\azure.png and be accessible from anyone in internet ?
In S3 (from Amazon) you can say if that object is public and then access it from certain url. Is that possible do that with Azure Storage service ?
I know is a lot of questions but for me it seems a little complicated to understand these things and how make them work for now.

Here are the answers to your questions:
The only 'official' way to access your storage account is through the REST API (or an SDK using this API). Besides that there are a few good tools that allow you to access your storage account:
http://www.cerebrata.com/products/cloudstoragestudio/
http://www.cloudberrylab.com/free-microsoft-azure-explorer.aspx
https://www.myazurestorage.com/ (web based!)
http://azurestorageexplorer.codeplex.com/
Public container allows you to get a list of all blobs available in that container and get container metadata. Public blob means you have to know the exact url to the blob in order to access it. Reference: http://msdn.microsoft.com/en-us/library/dd179354
Directories don't really exist. Just rename your blob in "mydir/myblob.txt" for example to simulate directories. If you use the tool by CloudBerry you will see the directory structure (I use this for storing files).
Change the container permission to public blob, upload the image. Then it will be available on the url (here I'm assuming your container is called image): http://YOURSTORAGEACCOUNTHERE.blob.core.windows.net/image/azure.png

Related

Azure storage options to serve content on Azure Web App

I am a total newbie to Azure WebApps and storage, I need some clarification/confirmation. The main thing to take note of, my application (described below) requires a folder hierarchy. Blob is out of the question and file share doesn't allow anonymous access unless I use Shared Access Signature (SAS).
Am I understanding Azure storage correctly, it's either you fit into the Azure storage model or you don't?
Can anyone advise how I can achieve what's required by the CMS application as described below by using Blobs?
The only option I see is to find a way to change the CMS application so that it always has the SAS in the URL to every file it requests from storage in order to serve content on my Web App? If so, is it a problem if I set my SAS to expire sometime in the distant future?
https://<appname>.file.core.windows.net/instance1/site1/file1.jpg?<SAS>
Problem with using Blob
So far my understanding is that Blob storage doesn't allow "sub folders" as it's a container that holds unstructured data, therefore I'm unable to use this based on my application (described below) as it requires folder structure.
The problem with using File Share
File share seemed perfect as it allows for folder hierarchy, naturally that's what I've used.
However, no anonymous access is allowed for files stored in file storage, the access needs to be authorised. One way of authorising the access is to create a SAS on a file/share level with Read permission and then using that SAS URL to access the file.
Cannot access Windows azure file storage document
My application
I've created a Linux Web App running open source CMS application. This application allows creation of multiple websites, for each website's content such as images, docs, multimedia to be stored on a file server. These files are then served to the website via a defined URL.
The CMS application allows for a settings of the location where it should save its files, this would be a folder on the file server. It then creates a new sub folder for every site it hosts in that location.
Example folder hierarchy
/instance1
/site1
/file1
/file2
/site2
/file1
/file2
Am I understanding Azure storage correctly, it's either you fit into
the Azure storage model or you don't?
You can use Azure Storage Model for your CMS Application. You can use either Blob Storage or File Share
Can anyone advise how I can achieve what's required by the CMS
application as described below by using Blobs?
You can use Data Lake Gen 2 storage account if you want to use Azure Blob Storage.
Data Lake Gen 2 storage enables hierarchical namespace so that you can use subfolders in the Blob Storage as per your requirements
Problem with using Blob
Blob Storage allows subfolders if we use Data Lake Gen 2 storage account. You can enable Blob Public Anonymous access
The problem with using File Share
Azure File Share supports but does not allow public anonymous access. You can use Azure Managed Identity (System-Assigned) for your web app to access the Azure File Share.
Then your application would be able to access the Azure File Share without SAS token
The issue of not having real folders in a blob storage shouldn't be any issue for your use case. Just because it doesn't have your traditional folders doesn't mean it can't serve content on e.g. instance1/site1/file1. That's still possible but the instance1/site1/ will just be part of the name of the blob.
Tools like the Azure Portal or Storage Explorer will actually show folders by using the delimiter / and querying data that appears to be inside a folder by using the path as prefix.

Azure storage account, make the file public with public link to download file

I have developed an app for a client with an azure database, I have never before worked with azure so I have no idea what I'm doing, I am using the .NETAutoUpdater package as the updater and require the update file to be a zip on a public link. Is there any to do this using Azure Storage Accounts --> Blobs and just make the blob public with a link? again I have no idea what I am doing in azure so any assistance will be appreciated
Yes, this is definitely possible. From the list of your blobs, click the grey dots at the end of the line and choose "Change access level".
Then change the access level to "Blob". Now open the blob container and select its properties view.
As you can see it shows an URL like https://yourapp.blob.core.windows.net/yourblobcontainer. Files that are placed in this container will be downloadable via that URL. E.g. if you have a file named foo.bar it'll be available at https://yourapp.blob.core.windows.net/yourblobcontainer/foo.bar.
It is actually fairly simple and straightforward to do. Simply set the ACL of the blob container containing your zip file to either Blob (recommended) or Container and the blobs inside that container will be publicly accessible.
You can set the ACL of the blob container on the portal, using any available storage explorers or programmatically.

Serving Files From Azure Storage

I have a simple need, but there are so many azure options, I am not sure where to start.
I have a AppService (website) on azure from which I want to serve static PDFs for download. In other words, there is a training page on the website, and on this page, I want to have url to the PDF to download it.
But I don't want the PDF's to be a part of the AppService files, I want them in storage so they are a separate from the website files.
How should this be done?
What I have found so far is: Azure Blob storage, but it's not clear to me how to use those with a URL. The samples look like they are using code to download instead of a public URL.
I have also looked at Azure CDN, but that seems like more than I am looking for. Just need a simple location to store and download files.
You can make the blob container public so anyone with the link can download the file.
In this case you can just link to the file or return a 302 redirect from your app to the link, which also initiates the download.
Another option is to use SAS tokens.
These temporary tokens are generated using your storage account access key,
and are attached to the URL.
You can then give this final URL in the link to allow the user to download the file.
In this option the container can be kept private, and you control who can access what.
Now the token is only valid until it expires (you decide this time), so a user could give the link to another person and they could also download the document within that time.
The third option is to pipe the files through your app to the user.
Download the file from your back-end and then stream it to the user for download.
This option takes more resources on your back-end as threads and IO are used there for each download.
This option is the most secure as you can control who can download what.
you can upload your PDFs to Azure Blob storage into a special container (e.g. download) and make that container and content public in either of two ways:
public read access for blobs only: Blobs within the container can be read by anonymous request, but container data is not available. Anonymous clients cannot enumerate the blobs within the container.
Full public read access: All container and blob data can be read by anonymous request. Clients can enumerate blobs within the container by anonymous request, but cannot enumerate containers within the storage account.
Then they are accessible by a URL like https://yourStor.blob.core.windows.net/download/train1.pdf
To expand on the accepted answer
Create a Storage Account, such as mystorage
In the storage account, create a container, such as mycontainer
On the container, set the Access Policy to Blob (Anonymous read access for blobs only).
Upload your file, such as myfile.txt to the container.
View the file Properties. It will show the URL to the file which is in this format: https://mystorage.blob.core.windows.net/mycontainer/myfile.txt
Note that the URL is case sensitive.

Uploading and accessing images with Azure

I want to upload some static images that I will later access via some mobile apps. I have an Azure Account that I rarely use so I thought that was the best place and therefore I uploaded them to a "File Share" within Azure Storage.
I naievely thought I could them just access those files via a simple web request url
https://myplace.file.core.windows.net/app/images/bnb/shop/bugle_200_2.jpg
All this gets me is a BadRequest error. I realize that I could create a Shared Access Signature (SAS) for every file but that seems total overkill.
Is there a better Azure feature to use? I do not want to have to use the Azure APIs to get at these files
Adding a few more points to #CtrlDot's excellent answer.
I completely agree that you should use Blob Storage for storing static content.
On the container permissions, I would actually recommend setting the permission (ACL) to Blob so that user can only view the blob they have the URL for and not enumerate all blobs in a container (setting container ACL to Container will enable the users to list blobs in a container which may not be a desired behaviour for you).
Other than these, there are two distinct advantage of using Blob Storage:
Custom domain: You can map blob storage to a custom domain (e.g. static content.mywebsite.com) and use that to serve the content instead of using Azure Blob Storage standard endpoint (your account.blob.core.windows.net).
CDN: You can also CDN enable your blob storage endpoint. The content will then be replicated across many CDN nodes spread throughout the globe and will be served from a node near to your user thus improving the user experience.
I think the service you should be looking to use is blob storage, not file storage. File storage, as per the documentation, is meant more for SMB shares.
When you setup Azure blob storage, you have a couple of different options. If there is nothing sensitive/secure about these static images, you could consider making a public container and simply accessing the files like that.
If you require authentication, then you need to either use azure storage access keys, or azure storage access tokens. Of the two, the storage access tokens are by far the most secure.
You wouldn't need to create a SAS token for each file, rather, grant it read permission to the container. Once again, you will have to tailor this to the security/sensitivity needs of your application.

Best Way to host dynamic image with Azure

I am working on a website where I need to dynamically host images. My intention is to host the images with full URL.
I tried CDN but come to know it has a limitation of that image will only be available 15 mins after upload.
Other options is Blob storage, when I read the document it says "Block blobs" are most ideal for image and media content. Therefore, I am trying to use that.
So, I've following questions:
What is the best way to host images on Azure for such requirements?
If I use Blob storage then how can I get the full URL so that I can that URL to load images in my product?
There really isn't a best way to store images. Some people store them in blob storage (as you referenced), some go with database engines... But, since you asked specifically about how to interact with blob storage and URI's:
All blobs are referenced by uri: http(s)://storagename.blob.core.windows.net/containername/blobname
You can set every blob to private or public (whether at blob or container level), and then either return URI's to your user/webpage (if public) or generate a Shared Access Policy or Shared Access Signature to temporariliy grant access to a private blob (I'll leave that as an exercise for you to look up).
It's completely up to you to create containers and blobs as needed. How you find a blob later is also up to you, so you'll need to think about how you store their names or their URIs (e.g. in a database table somewhere). You can always iterate through containers to search for a given blob, but that is time-consuming, vs direct-retrieval (again, assuming you've stored the URI as metadata somewhere in a database).

Resources