15
Demo Script Using Blobs Lab version: 1.0.0 Last updated: 3/16/2022 Prepared by: David Aiken

Windows Azure using Blobs Demo - skydev.pha.jhu.eduskydev.pha.jhu.edu/windowsazureplatformkit/demos... · Web viewThis document provides setup documentation, step-by-step instructions,

Embed Size (px)

Citation preview

Demo ScriptUsing BlobsLab version: 1.0.0

Last updated: 5/12/2023

Prepared by: David Aiken

ContentsOverview 3

Key Messages......................................................................................................................................... 3

Key Technologies.................................................................................................................................... 3

Time Estimates........................................................................................................................................ 4

SETUP AND CONFIGURATION................................................................................................................. 4Task 1 –Run the dependency checker 4

DEMO FLOW.............................................................................................................................................. 5

OPENING STATEMENT............................................................................................................................. 6

STEP-BY-STEP WALKTHROUGH.............................................................................................................6Uploading pictures to blob storage..........................................................................................................6

Viewing the blobs using the Azure Storage Explorer tool......................................................................10

SUMMARY................................................................................................................................................ 11

KNOWN ISSUES...................................................................................................................................... 11

Overview

This document provides setup documentation, step-by-step instructions, and a written script for showing a demo of Windows Azure. This document can also serve as a tutorial or walkthrough of the technology. In this demo you will show how you can use blob storage to store images, what configuration is required, and how you can use the Sample PowerShell provider to view and navigate blob storage. For additional demos of the Azure Services Platform, please visit http://www.azure.com.

Note: This demo uses the local developer fabric only. You do not need an account for the cloud

Key Messages

In this demo you will specifically see three key things:

1. First, you will see the configuration required to access Blob Storage using the Developer Storage service.

2. Second, you will see how to write code that connects to and creates new contains and blobs.

3. Finally, you will use the Windows PowerShell sample provider to view the blobs stored in the local Developer Storage.

Key Technologies

This demo uses the following technologies:

1. .NET Framework 3.5 SP1

2. Visual Studio 2008 SP1 or Visual Web Developer 2008 SP1

3. Windows Azure SDK – November 2009 CTP or later

4. Windows Azure Tools for Microsoft Visual Studio November 2009 CTP or later

5. Windows Azure Services

Time Estimates

Estimated time for setting up and configuring the demo: 10 min

Estimated time to complete the demo: 10 min

Setup and Configuration

This demo does not have any advanced configuration requirements. You simply need to have the pre-requisites installed and have a developer account for Windows Azure.

Task 1 –Run the dependency checker

The following steps describe how to run the Dependency Checker utility included with the lab to verify that you have the pre-requisite components properly installed. You can skip this exercise if you are confident that the pre-requisites are properly installed and configured.

1. Run the StartHere.cmd command script located in the directory that contains this demo.

2. The StartHere.cmd script will launch the Configuration Wizard. The Configuration Wizard is designed to check your machine to ensure that it is properly configured with all of the dependencies to build and use the Azure Services Platform Management Tools.

3. Click through the steps in the Configuration Wizard. The Required Software step will perform the actual scan of your machine. If you do not have the necessary dependencies, then install them using the links provided by the dependency checker and rescan your machine.

Demo Flow

The following diagram illustrates the high-level flow for this demo and the steps involved:

Open the Guestbook Project Show the Blob Storage Configuration

Walk Through the code that connects to and creates the

container and blobs

Upload a picture to the blob storage using the guestbook

application

Connect to the blob storage using Windows Powershell

Copy the blob containing the image to local storage to view.

Opening Statement

In the next few minutes, we will look at how you can use blob storage to store photographs. Once again, we’ll use the GuestBook demo application, and review the code already implemented and working.

In this demo you will specifically see three key things:

1. First, you will see the configuration required to access Blob Storage using the Developer Storage service.

2. Second, you will see how to write code that connects to and creates new contains and blobs.

3. Finally, you will use the Windows PowerShell sample provider to view the blobs stored in the local Developer Storage.

Step-by-Step Walkthrough

This demo is composed of the following segments:

Uploading pictures to blob storage.

Viewing the Blobs using the Powershell provider

Uploading pictures to blob storage

Action Script Screenshot

1. Start Visual Studio 2008 or Visual Web Developer 2008 SP1

2. Select File -> Open Project

3. Select GuestBook.sln

Let’s Open an existing Windows Azure project.

In the following demos we are going to use the Guestbook application.

The Guestbook application is a simple application that exercises many features of the Windows Azure platform.

4. Once the solution is open, point out the projects:

a. GuestBook_Data contains the classes for the data entities used by table storage

b. GuestBook is the cloud project. This is what defines the structure of the cloud solution, which roles are present and any service configuration.

c. GuestBook_WebRole is the asp.net project for the web role

d. GuestBook_WorkerRole is the worker role, written in VB.

As you can see we have several projects

Most of the projects are simply either standard class libraries, or asp.net web sites.

The important project for us is GuestBook

This defines the structure of our service.

You can see it has 2 roles, GuestBook_WebRole provides the web role, and GuestBook_WorkerRole provides the worker role.

For this demo we’ll be looking at the WebRole and the

GuestBook_WebRole ASP.NET project

5. Open the ServiceConfiguration.cscfg file.

The Guestbook application uses blob storage to store the photographs that are uploaded.

WebRole and WorkerRole are configured to use development storage.

6. Hit F5 to execute the application.

7. Right click on the development fabric icon in the system tray and click “Show Development Storage UI”

If we take a look at the local Development Storage, we can see the endpoints for the 3 storage services.

The UI also allows us to restart the development storage, as well as “Reset” the storage.

Resetting the storage clears the contents, which is useful for testing.

You can also stop and start the services, which again is useful for testing error handling and failures.

8. Highlight the BlobStorage code shown. (Default.aspx.cs – line 89)

Now let’s take a look at the code that implements the blob storage.

The CloudStorageAccount method, reads and parses the storage account information from the configuration

we saw earlier.

Next we must make sure the container exists.

We can do this by calling GetContainerReference and passing in the name of the container and then using CreateIfNotExists method.

9. Highlight the container code. Note the container has no metadata (null) associated, and is specified as Public. Public means you can access to contents without the sharedkey (meaning you can hit it with a simple URL). Writing still requires the sharedkey.

10. Highlight the code shown (Default.aspx.cs – line 37)

Now we have the container, we need to create the blob for the image.

First we need to ensure the filename is unique. For this demo, we use a combination of the word image and a guid to guarantee uniqueness.

This UniqueBlobName is then used to create some BlobProperties. The BlobProperties are used when creating the actual blob.

11. Highlight the code shown Based on the content type of the

incoming file, we set the same content type on the blob properties

12. Highlight the code shown Finally, we can upload the file content to blob.

13. Switch to your browser (GuestBook application).

14. Write a message, add a name, and choose a photo.

15. Click pencil icon.

16. After a short amount of time the image should be shown correctly.

Let’s run the GuestBook, and upload a picture.

Lets add a quick message and upload an image to blob storage.

We can then use Powershell to view the blob.

Viewing the blobs using the Azure Storage Explorer tool

Action Script Screenshot

1. Download and install Azure Storage Explorer.

2. Open and configure the development storage account.

Now let’s go and view that blob in the local storage using Azure Storage Explorer.

Azure Storage Explorer is a useful GUI tool for inspecting and altering the data in your Azure cloud storage projects.

After installation, we need to configure the local storage account.

3. Go to configured account.

4. Navigate to Blob Containers

We can see the blob containers, queues and tables created by GuestBook.

Guestbookpics is the container used by the GuestBook.

5. Select the blob ending with thumb.jpg

Lets view the contents of this container

We can now see all the blobs stored in this container.

Summary

In this demo, you saw how you can use the Storage Client assembly to create containers and blobs. You also saw how you can use the Azure Storage Explorer to view data from blob storage.

Known Issues

Please note the following known issues with this demo:

If the Developer Storage is not shown in the system tray, try running the GuestBook application, or launching the service from the start menu.