Azure Web App Where Do Store Uploaded Images?
This is an astonishing experience for me to work with Azure Blob Storage in ASP.Internet MVC awarding. I am going to share some advanced office which I have learned.
Equally nosotros all know Azure Blob Storage is used to shop the Binary Large Objects [Blobs]. Here nosotros tin shop and retrieve different kinds of information like images, documents, media files, etc.
Agenda of this Commodity
What is Blob Storage
Windows Azure Blob Storage can store the hundreds of terabytes data in one account. As yous know you tin can create multiple hulk storage account, then definitely you can shop multiple hundreds of terabytes information with Windows Azure Hulk Storage.
We don't require taking tension about the backup of the data which is stored on blob storage. It is because it automatically takes the backed upwards data. You can increase your storage every bit per requirement and you need to pay only which you lot take used and what you take used.
One more matter, I desire to consider here that you don't need to have headache nearly how to manage your data, your VM or whatsoever other things; actually Windows Azure manages everything automatically.
Yous can use Blob Storage as REST API and tin can apply with whatsoever language like Java, .NET, etc. Actually engineering science doesn't affair with blob storage. It means all kinds of customer tin can be attainable to this storage.
Yous can likewise visit this commodity for brief about Windows Azure Storage.
Why Hulk Storage
Persistency is the master advantage because we use Blob Storage. Actually there are many ways to share your static content or files to someone. You can store it on Hard Drive just these instances are non persistent. If you are going to use VMs and so information technology is managed automatically by Windows Azure and you don't demand to worry nigh this.
So, basically you lot are going to put your information in persistent store for long term uses then you need to get with Hulk Storage.
Create Blob Storage Account
There are unlike kinds of storage with Windows Azure similar Tables Storage, Queue Storage as well as Blob Storage. Today nosotros are going to piece of work with Blob Storage.
To start with Hulk Storage, first you should have a Azure Account as well as Blob Storage account. If you lot don't have the Windows Azure Account, you lot tin try with Gratis Trial.
If y'all have MSDN subscription then you tin can take benefits to your credit limits.
To login with Windows Azure Portal, you just need to get with Azure portal. Provide your credentials to login and enter the Portal.
When you complete you successful login with Azure Portal then you volition become to the following page [See the following image].
To create a Blob Storage account, click to New option which is resided in the following,
When you click to NEW and so choose Data Service option then choose Storage, then Quick Create.
It will requite you the window where you tin enter your blob storage URL and location [which region you want to create your hulk storage]. So, here you need to provide the storage proper noun in URL textbox. One matter you need to consider hither that proper noun is globally unique. When y'all are going to choose your blob storage location, delight note that it will be your main location where your blob storage data eye will be resided.
Below you will notice one more option "Geo Replication". If you select this option, the replica of your data volition be stored on unlike location in aforementioned region. Now it is time to create your Hulk Storage. And so, click on CREATE STORAGE ACCOUNT.
It will take few minutes to create and configure your storage business relationship. Actually it create all types of setting for your storage business relationship.
After few minutes, you will find that your storage account has created successfully. You will get a successfully created bulletin in status bar.
From the below status bar carte du jour, you can find one more option there and information technology is "MANAGE ACCESS KEYS". Really we need admission key to work with storage business relationship.
Then, click on the MANAGE ACCESS KEYS which is resided at lesser of the screen.
Here y'all will come across two types of the access key, i is main and other i is secondary respective to your storage account. You lot can copy your storage account access key to click on Copy icon at the right side. If you think that someone knows the storage access key then you tin can regenerate the access key using the "regenerate" pick.
So, finally we have successfully created the storage business relationship on Windows Azure. At present information technology is time to access the account. At that place are different types of fashion to access your hulk storage.
Install and Use Azure Explorer
If you are working with Windows Azure Blob Storage and storing some files then you lot need to view, rename, and delete the files. Then, yous tin use the Azure Explorer to access your blob storage.
You have to install Azure Explorer to your system to direct admission to your hulk storage. So, you can use link to download your azure explorer.
Click on Download, within few seconds, you lot will get the setup file for Azure Explorer. Click on the setup file to run the setup and information technology volition be going to install the Azure Explorer for you.
When it will be installed successfully, an application icon will exist gear up inside the program carte du jour. Go to start and notice Azure Explorer and click on it.
It volition ask for license terms and conditions. Yous need to check on checkbox and click on I Accept.
So, yous have installed Azure Explorer successfully. It will open the azure explorer for you lot as in the following. Here you will find the Azure Storage Business relationship choice where you volition be finding the unabridged containers which contain the blob for you.
To add your account with Azure Explorer, Correct click on Azure Storage Business relationship and choose Add Connexion to Azure Storage.
Information technology will provide y'all dissimilar way to connect with storage account. You demand to choose "Connect to Azure with an Storage Account Proper noun and an Admission Cardinal". As we know that nosotros have got access key earlier and click to Next.
In the adjacent "Add Windows Azure Storage Business relationship", provides you storage account proper name and storage access key.
If y'all want to test your connection, you lot tin can use "Test Connectedness" push button.
And so, finally we have added our account with Azure Explorer. You tin can see my storage account "mukeshdemostorage" added successfully.
As we all know that there should exist a container to store the blob inside storage business relationship. So, for creating the new container for hulk, Correct click on your storage account "mukeshdemostorage" and choose New Hulk Container.
It will open a dialog window where you tin can specify the proper noun of the Blob Container and Access Level. I am going to provide the name every bit "sampleimage" [Name always should be in small letters] and there access level equally Private.
And so, it will create a blob container "sampleimage" for me. As it is an azure explorer. Y'all tin can direct paste the documents or files inside it. I am going to paste [Upload] 1 of my images directly inside the "sampleimage" hulk container.
So, yous can meet that ane prototype is available with name "Mukesh Kumar". Right click on the image and click on Re-create Path. Information technology will directly copy the path of image which is resided on the server.
Going to admission the image, you can paste the URL inside the browser and press enter. You will see the post-obit error which says that y'all tin't access this file considering the access level of this file is Private and y'all tin't access it from outside as publicly.
So, you demand to change the access level of your blob container.
When yous again try to access the aforementioned URL inside the browser, you lot will observe the image is uploaded through the Azure Explorer.
Create ASP.NET MVC Application
Nosotros have successfully uploaded and access the same epitome from Azure Explorer. Information technology is very easy. But how it is possible through an application, and then, complete this task I am going to create an MVC application from where I will endeavor to upload an image within the hulk storage and admission it.
So, create an MVC awarding "BlobStorageDemo" with No Authentication.
As I am going to upload an image, so create a controller "ImageController" from where we will perform all the activity of the prototype. Right Click on the Controllers, Add, then Controller.
Provide the proper name of the Controller as "ImageController" and click to Add together.
Install Storage Client Library and Configuration through NuGet
Generally when nosotros create a simple awarding there is no reference of the Storage Client Library. So to add this I am going to use NuGet Packet Manager.
Correct Click on the project and choose Manage NuGet Packages.
It volition open up NuGet Package Manager for y'all. Type the azure storage inside the search and it will give you the following bundle which tin can be installed. You lot need to choose WindowsAzureStorage and click to Install.
It will requite y'all some preview what information technology is going to install packages.
It will accept few minutes to install. When it will install successfully, you will be finding lots of extra references inside the Reference section along with WindowsAzure.Storage.
You can also install Azure Configuration to admission the configuration setting in application.
Upload Image through ASP.NET MVC Application
So, going to admission the blob storage through your services or controller, you need to utilize blob storage admission cardinal. Then, for the security purpose you tin store it inside the configuration files. Subsequently nosotros can access information technology someday from anywhere.
I am going to create a class "ConnectionString.cs" from where I will access the storage account name and storage admission key and create the connexion string for blob storage. Please brand sure you need to use two namespaces.
To accessing the Storage Account, You lot can access information technology through the CloudStorageAccount form which tin be accessed by account name and access key. Using the instance of the CloudStorageAccount, you can admission and create the case of the CloudBlobClient. But without accessing the blob container you tin't access the resource which is resided in container. And then, in this instance, we demand to utilise the CloudBlobContainer.
To admission these Storage classes, you make sure you are adding the post-obit namespace.
As we are going to upload and show the latest uploaded image on the view, nosotros need to make changes in the controller as in the post-obit. I am going to upload epitome through the "Upload" Action and showing the latest image through the activeness "LatestImage",
To upload and testify the latest prototype, I take created two different views. For uploading you tin useupload.cshtml and for showing the latest image use LatestImage.cshtml.
It is time to run the project. And so, runt the project to press F5 and go to the following page to upload the image, here you lot can cull a image which is going to upload and click to submit.
When you click submit, it will upload your image inside the sampleimage blob storage container. And redirect to latest image page with latest uploaded prototype.
You can check your uploaded prototype to refresh the Azure Explorer.
Decision
So, today we have learned what blob storage is and why we demand to employ information technology. Nosotros have used blob storage to create an account with ASP.NET MVC application.
Suggest, what exercise yous think?
Thanks for reading this article, hope yous have enjoyed information technology. Please share your valuable feedback and suggestion through comments.
mcanultyaborted47.blogspot.com
Source: https://www.c-sharpcorner.com/UploadFile/8a67c0/upload-image-in-azure-blob-storage-with-Asp-Net-mvc/
0 Response to "Azure Web App Where Do Store Uploaded Images?"
Post a Comment