Using Azure Content Delivery Network—Safely

2521 VIEWS

A content delivery network is a great way to store and provide access to files to be used and disclosed many different ways by URL. This post is a step-by-step guide on how to add the Azure CDN into your web application, and how to use the Microsoft Storage Explorer storage tool.

How can CDNs be useful?

A content delivery network is a large, distributed system of servers installed in various data centers around the world. The primary purposes of CDNs are to provide high-performance availability, and end-to-end online content distribution.

Storage Explorer is a cloud storage application designed to make it easier to work with storage data with an Azure account across multiple platforms. In this article, we will use the storage in blobs—This is one of several features of the Storage Explorer.

Creating an Azure Content Delivery Network

Through the following configurations, we will configure the CDN in Azure, so you will need to have an account there. Log in to the Azure portal, search for CDN Profiles, and click Add to create and configure the service.

On the Azure Content Delivery Network creation page, complete the CDN information on the form. Enter the name, select the subscription, the resource group, the region, and the pricing tier, and click Create. The price level we’ll choose is the Akamai Standard, which is the best value for our example, but there are other options, depending on the project in which the CDN will be used.

The name of the CDN endpoint will be the name used to create the URL to access the data stored in the container. For this post, I used the name containercfb967, which generated the endpoint URL containercfb967.azurewebsites.net. After creation, you can view your service on the page that lists the active CDNs for your subscription.

Creating Your Azure Storage Account

Search for storage accounts, and click Add to create a storage account that will be connected to the previously created CDN. Fill out the form by choosing the Resource Manager for Deployment model option. Choose the same signature, resource group, and region you chose when creating the CDN. After creation, you can view your service on the page that lists the active accounts storages for your subscription.

Configuring the CDN

On the CDN Profiles page, click the containercfb967 service to view the CDN configuration options. Here, the endpoints configured for the CDN are displayed. Click on the single endpoint to configure its origin. In the endpoint settings, access the Origin option from the side menu located in the Settings group.

Now we can associate the CDN with the storage account defining where the data will be stored to be made available through a URL. In this form, choose Storage for origin type; select the storage account created for the option Origin hostname, and in the Origin path field, include images so that only this directory is accessible, and click Save.

Connecting with Storage Explorer

On your computer, download and install the Storage Explorer application. Go to the Connect to Azure Storage option and paste the key from your storage account. You can find this key through the Access Key menu of the storage account. In the next step, paste the name of your storage account to end the connection.

In Blob Containers, right-click to include a container called images. With the images container selected, add some test images simply by dragging them to the Storage Explorer.

You can already access your images by copying the URL provided by Storage Explorer, but this URL will display the full path to your storage account (and we do not want to share this information with the world).

Creating a Custom Domain

For this, we will add a CNAME entry in our DNS called cdn that points to the address of the endpoint hostname. Then we will access the CDN settings again to add the Custom domain where we will add cdn.domain.com to the Custom hostname field. The process of validating this custom domain is time-consuming; you must also enable HTTPS. You will receive an email to verify the domain. Once you have verified it, you will be able to access your files through the domain defined in the DNS.

Conclusion

As demonstrated here, configuring a CDN in Azure is a simple task that does not require lines of code or templates. You can also upload files to the storage account directly through the Azure portal web interface, but using Storage Explorer makes file management much easier. It is important to note that the storage account alone already does the work of making the files available via URL, but with the CDN, we can configure file compression and hide the real path to file access, providing more security for our data.


Brena Monteiro is a Tech Lead passionate about mentoring new developers. A professional who has experience in the hire, mentoring, and leader development teams, and building scalable APIs and integrates it with partners and cloud services. Enthusiastic about architectural improvement using cloud services.


Discussion

Leave a Comment

Your email address will not be published. Required fields are marked *

Menu
Skip to toolbar