Let me explain how to upload something to Azure cloud blob with a detailed progression report.
First, create a Cloud storage in Azure and name it as somegoodstorage
Now create a Container in that storage called somegoodcontainer
Now open Visual Studio and create a blank console application.
We need to add Azure Storage references for the current project to continue with out main task. So, go through Tools -> NuGet Package Manager -> Manage NuGet Packages for Solution.
There search for Azure Storage and install that package to the project.
Now again go to Azure management portal and go to the dashboard of the previously created somegoodstorage storage and get the primary accesskey to access the storage programmatically by
If you see line 6 – 9, we are calling all necessary references to the project from those lines.
After that we create a new
StorageCredentails object that refers to the cloud storage. You can see we directly say its name somegoodstorage there and please don’t forget to replace the Accesskey.
Line 28 says the file that we are going to create on the Azure storage. If you miss the extension for the file or the file type, you will still get the file but without any filetypes.
Line 29 called the VacancyAd.jpg file from C:\ and upload it.
Again in Line 29, you may notice something
System.IO.FileMode.OpenOrCreate this means, system should open a file if it exists; otherwise, a new file should be created. There are several FileMode enumerations are there, read them from http://msdn.microsoft.com/en-us/library/system.io.filemode%28v=vs.110%29.aspx
Thats all folks, easy nah… 😉