Learn how to set up Visual Studio to work with Blob storage on Azure.
- [Instructor] We now have our storage account on the portal, on the dashboard. Let's go ahead and click on that, and we see a review of what we've selected for this storage account. On the left, under Settings, we see Access Keys. We have a couple keys and a couple connection strings, key1 and key2 are what we're going to focus on right now. I'm going to copy key1. You do not want to distribute these keys.
These you want to keep private. There are alternatives for distribution but that's an uncommon thing to need. We're going to copy key1 and hold on to it. Now we need to create an application that can illustrate how blob storage works but there's a fair amount of complexity to that and Microsoft provides a sample application that illustrates all of the aspects of blob storage, so that's what we'll be using for this part of the course.
You're going to want to navigate to the Blob Storage Samples for .NET. Here you can browse them on GitHub, but for our purposes, it's just as easy to simply download the .zip file. That will download it to your Downloads folder. So you can see this in your Downloads folder and as you see, you have a .zip file. Right-click on the .zip file, choose Properties, and make sure you click Unblock, and that will tell Visual Studio that this a safe set of files to use.
Click OK. You can now right-click and say Extract All. You're going to extract it to the same directory. So let's go ahead and extract, and now you have the extracted folder. Double-click on that, click your way in, and we're going to open up the solution file, double-click, and that will open up Visual Studio. Visual Studio will tell you that some NuGet packages are missing. We're going to go ahead and click Restore even though we'll be updating these.
They're now completely restored. However, we're going to want, and you'll see this in just a moment, we're going to want to update those. Before we do, let's go to App.config, and you'll notice that there are two storage connection strings. The first one, which is the default, uses the emulator. However, we actually have an Azure account and it will be more meaningful and more instructive to use the Azure account rather than to use the emulator.
So we're going to comment out the line that would use the emulator, and let's put the end comment here, and we're going to uncomment the line that uses Azure, and let's go to the end of that line and take out the comment. Now the only complication is that you need the account name and the account key. The account name is the name we gave to that account, so we can go back to the portal, and we see that the account name in the upper lefthand corner is jlblobstorage.
Going back to Visual Studio, we can put in the account name, take out the brackets and AccountName which is just a placeholder, and put in the actual account name jlblobstorage and then we're going to need the account key. We had copied that but now I've copied over it so let's copy it again, come back to Visual Studio, and replace AccountKey with the actual account key.
All right, the next thing that we want to do is, as I mentioned, update the NuGet libraries. To do that, we're going to go to Tools, NuGet Package Manager, and this time, instead of using the console, I'm going to go ahead and use the manager for NuGet packages. This shows me all of my installed NuGet packages. I'm going to go to Browse, and the first one that I'm going to browse for is windowsazure, as one word, dot storage.
And that brings up WindowsAzure.Storage. I'll go ahead and click on that. Notice that the installed version on mine is 7.0.0. Yours may vary. And the latest version, the latest stable, on mine is 8.2.1. Once again, yours may vary. But what we're trying to do here is to update to the latest version. So we'll go ahead and say that we want to install that to our project. It's going to gather the dependencies, and then it's going to show what changes it's making, and in this case, you can see that it's updating a number of libraries.
We'll say OK, it's going to ask about licensing, we'll accept the licensing, and that's going to add all the packages and their dependencies. If it comes up and says that they are unchanged by external changes, we'll say Yes to All, and that's because of the update to the libraries. Now we're going to go back and Browse under NuGet, and this time we're going to say WindowsAzure.configurationmanager.
That will bring up immediately the Windows Azure Configuration Manager. Click on that, and we have the same situation. In my case, the installed version is 3.2.1 and the latest stable version is 3.2.3. Your mileage may vary. Let's go ahead and install that, review what we're going to install, accept the license, and that package will be installed.
- Creating an MVC web app
- Publishing an MVC app to Azure
- Creating a SQL database on Azure
- Enabling migrations
- Updating an Azure database
- Changing the schema
- Exploring various types of Blob storage
- Creating Blob storage accounts in Azure
- Examining Azure statistics for monitoring Blob storage