Ricardo Sanchez
Coder, Photographer, Youtuber, Blogger

Azure

What can you do with Azure Functions? Here’s one example.

Last week I attended a tech conference where I learned about Azure Functions. This new service from Azure, Microsoft’s cloud platform, is something that got me interested. Microsoft is promoting this new service as a server-less option for simple APIs, triggers, notifications, and anything that you can think of that can be processed by a function, regardless of the programming language used.

It’s worth mentioning that just like with any other cloud service or feature, Azure Functions isn’t the solution for everything. However,  Azure Functions are really helpful in supporting your application without the need to provision a new full-featured API, servers, etc.

In this blog post, I will show you an example of an Azure function that serves as an API endpoint, returning text from a simple call to it. Continue Reading

Create and Deploy a React App to Azure using .NET Core and Azure CLI on Mac

Prerequisites

Getting Started

In this tutorial, you’ll set up your Mac to do development using .NET Core and Azure. The tutorial also shows you the new and powerful .NET Core Command Line Interface (CLI) Tools.

After you have installed the .NET Core SDK and Visual Studio for Mac, open a terminal window and type the following:

$ cd /users/

$ cd users/yourusername/projects

$ mkdir samplereactapp 

$ cd samplereactapp

The above commands will do the following: browse to the Mac user’s Projects directory and create a new directory to place the react app that we are about to create.

.NET Core CLI

.NET Core’s Command Line Interface (CLI) is very powerful, it allows you to do a lot without leaving the command line which allows for the simple and fast creation of these projects. Double-check your current directory is the new directory you’ve created, in our example this is samplecreateapp. 

To make sure the .NET Core was installed properly, type dotnet –info in the terminal, you should see output that looks like this:

Once you have confirmed that you have all the needed prerequisites, let’s continue to build the React web app. Continue Reading

How to serve static files for your website using Azure

Killer features and a beautiful design are important things when developing a website. However, none of that matters if your site doesn’t perform well or is not able to scale when necessary. Serving static files such as CSS and images from your web server is not ideal.

These are some of the disadvantages of serving static files directly from your web server:

  • Unnecessary deployment of files that do not change often, potentially slowing the deployment process.
  • Increase the load of your web server, making it less responsive.
  • Increase of hosting costs
  • Etc…

Here are some of the advantages of not serving static content from your web server:

  • Distribute web server load.
  • Save bandwidth.
  • Boost performance and reduce your existing hosting costs.
  • Ability to update static files by replacing them in CDN without having to deploy entire website.
  • Etc…

In this blog post I will show you how to take advantage of Microsoft’s Azure CDN and Blob storage to make your website serve all of its static content from the Azure CDN. If you don’t have an Azure account and you are a web developer you are missing out. Azure supports a wide range of frameworks and technologies including but not limited to Python, MySQL, Oracle, Java, Linux, PHP, Ruby and of course all of Microsoft products such as .NET, MS SQL, etc… Also, they offer a program for startups called BizSpark where you get Azure services for free, you can sign up here if you like.

Create a Blob storage account and a container

First of all you need to create a blob storage account and then a container which you’ll use to store all of the static content. To do this open your Azure portal and then click on the + NEW button located at the bottom left corner of the portal and select Data Services > Storage > Quick Create > as shown below, then just type a URL to identify this new blob storage account. In this example I used the name “mystaticfiles”.

Create Blob Storage Account Image

It takes approximately 1 minute for the blob storage account to be created. Think about it, it takes a minute (or less) to deploy a blob storage account/instance capable of logging, monitoring and redundancy.

After that you’ll see your newly created storage account, click on the name of it, then on the Containers link and then on Create Container as shown below:

Create Storage Container Image

After the Create Container window opens, type the name of the new container and its access type. For this example we are going to select Public Blob which allow us to have a container where all files are available to the public. The other two options are Private which makes the container available to you only and Public Container which allows anyone to have access to the files, metadata and pretty much everything else in this container.

create container in Azure

Manage the blob storage account and container

Now that you have your new storage account and container, you can start transferring static files from your website to the container(s) you’ve created. To do this, you can either write a service that does this for you or use one of the programs available that help you manage your containers and files in an Azure storage account.

I found an open source application to help me manage my storage accounts and containers and so far it has worked out very well for me. If you are interested, you can download it here and even get the source code for it too:

Azure Storage Explorer

You can use this application to browse your files as well. Once you have all your static files in your Azure blob storage containers you can then update your static file’s path to point to the Azure containers. For example, here is a link to one of my images stored in Azure blob storage:

https://foreverbitapp.blob.core.windows.net/images/journal9_medium.jpg

Are you using Azure blob storage? please share any tips or feedback in the comments below.