Logo
programming4us
programming4us
programming4us
programming4us
Home
programming4us
XP
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server
programming4us
Windows Phone
 
Windows Azure

Hosting static HTML websites (part 2) - Publishing your website to BLOB services

3/14/2011 10:26:01 PM
- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019

2. Publishing your website to BLOB services

You’ve programmatically added your BLOBs to the storage service. In this example, you’ll make use of a tool called Chris Hay’s Azure Blob Browser (can you guess from the title who created it?) to upload the files to BLOB storage. Figure 4 shows the addition of the calculator.js file to BLOB storage via the tool.

Figure 4. Adding calculator.js to BLOB storage via Chris Hay’s Azure Blob Browser


Using the BLOB browser, you can add each file of the website (default.htm, calculator.js, standard.css, and happy.jpg) by selecting the file to upload, setting the MIME type (which is automatically predicted for you, but is also editable), and clicking the Add button.

After all the files are uploaded into the appropriate public container, you can access the website with a standard web browser using the following URI structure: http://silverlightukstorage.blob.core.windows.net/azureinaction/default.htm.

Note that you must include the filename (default.htm) because BLOB storage doesn’t support default documents.

Tip

If you’re hosting your website or web application in BLOB storage, you probably don’t want your clients to use the BLOB.core.windows.net domain. You need to host your website on your own custom domain, for example, http://www.noddyjavascriptcalculator.com/


Setting the Correct Mime Type

If the correct MIME type isn’t set, the web browser won’t be able to render the downloaded file. Some browsers, such as Internet Explorer, will render the content in some situations even if the MIME type is incorrect; other browsers, such as Firefox, require the MIME type to be set explicitly.

Figure 5 shows how Firefox handles HTML documents that don’t have the correct MIME type (text or HTML) but instead use the default Azure BLOB storage services MIME type (application/octet-stream). Figure 5 shows that Firefox can’t display the page and requires further instructions from the user. If the MIME type is set correctly, Firefox will show the web page that’s shown in figure 3.

Figure 5. Accessing a file that has an incorrect MIME type in Firefox


Now that your first static HTML website is running in BLOB storage, let’s look at how you can move beyond flat directory structures and store and retrieve files within hierarchies.

Handling Directory Structure

In our calculator example, we used the following flat directory structure for the files:

  • default.htm

  • calculator.js

  • standard.css

  • happy.jpg

Although this kind of structure is useful for small websites, it’s limiting for websites with a large hierarchy. BLOB storage technically doesn’t support directories within a container, but you can simulate such support by using a slash (/) as a separator in the BLOB name, which creates a hierarchy for the files. The following list shows how you can represent your files in BLOB storage:

  • Chapter10/default.htm

  • Chapter10/javascript/calculator.js

  • Chapter10/css/standard.css

  • Chapter10/images/happy.jpg

Using the slash separator in the BLOB name means that the default.htm page would be accessed using the following URI structure: http://silverlightukstorage.blob.core.windows.net/azureinaction/Chapter10/default.htm.

The CloudBlobDirectory class in the StorageClient library provides a way around the limitation of containers not having subcontainers (or subfolders) by providing a set of methods that allows you to pretend that there’s a real directory structure in a container. It’s driven by the slashes you put in your BLOB filename.

Now that you’ve made this example website, you can tell that using BLOB storage as a web server is pretty cool and simple. There is, however, one drawback.

Logging BLOB Requests

As of version 1, BLOB requests aren’t logged. This level of logging is vital for analyzing who’s visiting your website, where they’ve come from, and what parts of your site are popular. If you’re used to running your own website, you usually have access to your IIS logs, which contain information such as page requested, IP address, referrer, and so on. Because the BLOB storage service doesn’t provide such information, if you’re going to use it to host HTML websites, you need to use an external analytics service, such as Google Analytics.

In this section, we showed you how to display static HTML websites in BLOB storage services. Next, we’ll look at hosting Rich Internet Applications (RIAs), specifically Silverlight applications.

Other -----------------
- Performing storage account operations using REST (part 3) - Creating a table using the REST API
- Performing storage account operations using REST (part 2) - Deleting tables using the REST API & WCF Data Services and AtomPub
- Performing storage account operations using REST (part 1) - Listing tables in the development storage account using the REST API
- Doing CRUDy stuff with the Table service (part 3) - Deleting entities & Updating entities
- Doing CRUDy stuff with the Table service (part 2) - Adding entities & Listing entities
- Doing CRUDy stuff with the Table service (part 1) - Creating a context class
- Developing with the Table service
- Partitioning data across lots of servers : Partitioning the storage account & Partitioning tables
- Modifying an entity to work with the Table service
- How we’d normally represent entities outside of Azure
 
 
Top 10
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
 
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server