Thursday, July 5, 2018

Static website hosting for Azure Storage

The public preview of static website hosting for Azure Storage has released on June 28, 2018! This is great news and it will be available in all public regions for azure and will also support government and sovereign clouds as well. Gone are the days where you treat static websites and web applications and allocate more resources than what they really need. This will save lot of costs as its just displaying files as it is.

A static website means there are no server side code. No database connections as well. A static website will consist of mark up pages, JavaScript and CSS. There are many such sites, probably in public portals which are used to host on Azure Web Apps. No anymore. 

A major part of cloud is about cost saving and being simple whenever possible. With Static Website hosting, there is no need for server management. Content are stored in Azure Storage and is going to help to be on Serverless. 


A new endpoint is created to host the static website with following pattern.

<account-name>.<zone-name>.web.core.windows.net.
Eg: https://statichost.z19.web.core.windows.net/

·      Supported Platforms
Net Client Library (version 9.3.0) 
Java Client Library (version 8.0.0)
Python Client Library (version 1.3.0)
Node.js Client Library (version 2.10.0)
Visual Studio Code Extension (version 0.4.0) and CLI 2.0 (extension version 0.1.3).
Storage Explorer and Powershell support will be available soon.
Storage Services REST API is available now.
Static websites is supported by REST API version 2018-03-28 and greater (Azure recommended using the latest always)

Source: Azure Blog

Being able to connect to REST API is a great advantage as well as it makes things possible as no need of managed code. Imagine if you need to display any weather data or some data from an RSS feed, they all can be included in your static website. 

·      How to Access
1.     Create a GPv2 Storage Account on Azure


2.     Click On the Newly Created Storage and you will see a link on settings section in the left navigation bar and Enable it.

3.     Upload web assets to $web Container. (Created when Static website enabled)
            


This can be done via Azure Portal or the extension available for Visual Studio Code to upload the whole directory to the server.


Static Web Sites will be publicly available to access. HTML content will be rendered based on if any specific logic is defined on JavaScript or any other script. By default, the index document will be returned as the landing page. Custom error pages can be configured to show up if any HTTP errors come in.

No comments:

Post a Comment