Configure Blob Storage with Public Access
This virtual lab and IT Pro Challenge teaches learners to find storage account details in Microsoft Azure and configure blob storage with public access using an ASP.Net framework. Learners on Data Analyst, System Analyst, Cybrary Operator, and Network Engineer career paths benefit from scripting web app access to a storage account in Visual Studio.
This hands-on experience guides learners to get information about a storage account in Azure and write C# code using an ASP.Net framework in Visual Studio 2017, to allow a web app access from and to an Azure storage account. You will connect to a virtual machine (VM) using the Remote Desktop Protocol (RDP). If you run the lab on a mac Operating System (OS), you will need to use Microsoft Remote Desktop and connect to a new PC. Once you open the visual studio project on the VM, you will set up the challenge, add and initiate a client field, upload a referenced file, and retrieve the URLs of the uploaded files through the code. Finally, you will verify that the web app can be used successfully and connect with the public storage account.
This virtual lab intends to teach beginners some experience in Microsoft OS and cloud environments and their familiarity with programming. If you have little programming experience, you will want to review the videoed hints. As you type methods, objects, classes, variables, and parameters, in Visual Studio, you can enter a few letters into the script and choose the correct term from a pull-down list. This strategy will help you complete the lab more efficiently.
The lab takes thirty minutes to complete, and learners cannot stop mid-way. However, lab participants can take the lab more than once. You will work in Azure Portal and Visual Studio 2017. You will be provided with a resource group, storage account, and a list of files and objects to complete the lab exercises successfully.
Those learners on the path towards a Data Analyst or a Database Administrator, learn about storage account characteristics. Participants working towards starting or advancing their System Administrator, Network Engineer, and Cybersecurity careers gain essential skills scripting a constructor (the client field), a container creation permitting public access, a file upload, and a list of a file data object. Participants learn C# by entering ASP.Net code in Visual Studio and test that a web app can upload and download files to and from a linked storage account.
Understanding the Scenario:
You are a developer for a company that is migrating its primary web app from its data center to Azure. You need to write code to access an Azure Storage account used by the web app. You write code to create a container with public blob access and then upload test files to the container. Next, you write code to retrieve the URLs of the uploaded files. Finally, you test the configuration using a test page provided with the web app.
Record the Storage Key:
This lab exercise teaches you how to locate the Azure portal's storage account name and its primary access key. You paste the information into the lab. Another application or person can use the primary access key to get contents from public storage. The key serves as a password to access data in the storage account.
Open the Challenge Project:
You connect to a remote machine and locate the challenge's programming resources. You open a .sln or solution file, as instructed, in Visual Studio, and a NuGet package containing compiled code for Azure Storage manipulation. You then set the 'testType' to 1 or true in the web.config file. That configuration activates the script. In the next section, you use Visual Studio to code a constructor or a client object.
Code the Constructor:
In this lab section, you start editing the StorageContent.cs file by creating and initializing a new storage account user, CloudBlobClient. When you create the constructor, CloudBlobClient, you define it and its properties. The cloud storage account class or blueprint describes what kind of thing CloudBlobClient can be. CloudBlobClient's class allows you to apply code to specify the account's credentials and authorization.
In the programming language C#, you learn that you form a constructor for a class by a method with no name and a return type that matches that class. The constructor in this exercise uses the "CreateCloudBlobClient()" method and return type.
Code the UploadFile Method:
This lab portion has you create a container if it does not exist and make it ready to access those files publically. Then, you reference a file to upload or blob for when the code runs in the "Test the Application" portion. To find out the data structure of the BlobFileData, refer to the contents at the top of the StorageContent.cs file.
Code the GetFileList Method:
Learners enter C# code so that the Azure storage container makes a list of all its blob files, and the Azure Web App can get this information. As a result, the storage container and web app can communicate with each other and access files. Typically a website uses Azure Storage REST API. REST or Representational State Transfer allows interoperability between computers, creating the web services needed to upload and download data from any machine.
Test the Application:
Learners test the Azure web app in this lab exercise. The web app provided by the lab contains a test page. Participants enter the storage account name and key you recorded in the first lab exercise. Then, users press the Test button to run an automated script created to upload and download a file. If the test does not execute successfully, learners may wish to check the scripting. The left margin shows red markings for troublesome code and a place to revisit the edits' video hint.
This lab will teach you how to find more about an Azure public storage container and how to use C# code to allow a web app access to an Azure public storage account. You will learn how to:
- Add Azure Storage capabilities to an ASP.NET MVC project.
- Access an Azure Storage account programmatically.
- Provision an Azure Storage blob container with public access.
- Upload files to an Azure Storage blob container.
- Retrieve a list of files from an Azure Storage blob container.
By lab completion, you will know how to manage Azure public storage through code and research more about the storage characteristics.
See the full benefits of our immersive learning experience with interactive courses and guided career paths.
In this IT Pro Challenge virtual lab, learners get hands-on experience in the Azure portal, ...
In this IT Pro Challenge virtual lab, learners configure an Azure storage account with a ...