Creating and Deploying App Function, Setup Redis & FrontDoor

Mohamed Thasneem
5 min readAug 24, 2020

--

Hello All, In my last article Setup MySQL and Service Deployment in Azure I have deployed the Permanent-Product Service using Azure App Service. In this article, we will be creating and deploying our Message Service using Azure App function.

Azure Functions allows us to run small pieces of functions without worrying about application infrastructure. It provides some key features like developing a server-less application, choice of language(Java, C#, Python, JavaScript, TypeScript), pay-per-use, simplified integration and flexible development and many more.

We will be using Azure CLI to create and deploy the Azure App Function. So let’s start.

First login to Azure CLI using the following command

az login

You will be prompted to the Azure login page in the browser.So login with your Azure account in the browser.

Next step, from inside an empty directory run the following command to generate the Functions project from a Maven archetype.

mvn archetype:generate -DarchetypeGroupId=com.microsoft.azure -DarchetypeArtifactId=azure-functions-archetype

Add the following configuration properties to create the Azure Function.

  • groupId: A unique identifier for the project. eg: com.thasneem
  • artifactId : eg : details-function
  • version: Project version. Keep the default.
  • package: Package name. Keep the default

So now the Azure Function is created in the directory so next, we will go and edit the code. You can check my Azure Function in my Github repository under the details-function directory.

So, for now, I will just return a welcome message, Later we will add some more configurations to integrate with a queue.

You can test your Azure function locally. So it will listen on http://localhost:7071

mvn clean package  
mvn azure-functions:run

Now we will deploy this function to Azure.

So first clean and build the project

mvn clean package

After successfully build you can run this command to deploy

mvn azure-functions:deploy

After successfully deployed you would get a success message like this.

So now we have deployed the function in Azure. So we can see the service in the Azure portal.

So now let’s check this using PostMan.

GET : /api/message

So that’s it we have deployed an Azure Function that responds to the HTTP requests. So in the next article, we will see the deployment of the Coordinator-Service.

Setup Redis Cache

Redis is one of the great choices to implement a highly available in-memory cache to decrease data access latency, increase throughput, and ease the load off your relational or NoSQL database and application. Redis stores data as key-value pairs and it supports different kinds of abstract data structures, such as strings, lists, maps, sets, sorted sets, HyperLogLogs, bitmaps, streams, and spatial indexes.

So in this article, we access the Azure Redis Cache and do some CRUD operations like ADD, VIEW, UPDATE, DELETE products using Coordinator Service.

First, we need to setup Redis Cache in Azure, So login to the Azure Portal and in the Databases category, select Azure Cache For Redis.

Next, click on the Access keys and copy your access keys. Keep your Access keys securely.

FrontDoor Setup

Front Door is a networking service in Azure that acts as a load balancer and application firewall. So first let’s look at some key features in using Azure FrontDoor.

  • Route users to the most performing application
  • Ensures users get routed to a working application. So if one application fails it routes to the other.
  • Protect application against DDoS attacks.
  • Path-based routing

In our application architecture Coordinator Service is the centralized service. The other two services Permanent-Product Service
and Message Service are requested through the Coordinator Service. So in case of any failure in Coordinator Service the other back end services
also will be down. So we need to keep our Coordinator Service up and running every time in order to keep our application
alive. Sometimes if high traffic comes to our Coordinator Service it might get down. So we need more instances of the Coordinator Service, so in case
if one fails the application work. We can spin up instances of the Coordinator Service in different regions, so front Door will route to the
nearest instance of the user.

So Let’s go and set up the Front Door to our application.

To load balance the traffic we need to spin up more number of the Coordinator Service. Already we have a Coordinator Service up and running in the West Europe region. First, we will spin up another instance of Coordinator Service in the East US region.

So we can deploy the JAR as we did in our previous articles.

In the hostname fill the hostname for your backend in you wish. If you need a firewall for your backend you can enable if you need. Then click Add.
Adding Backend pool. We can add a pool(group) of backends for Frontend to connect when you click the plus button in backend pool box you will get a window to add backends and initialize pool name.

That’s it review and create. we had created our Front Door.

We can now use Frontend URL in my case ThaDemo.azurefd.net as an endpoint for Angular application we had deployed earlier.

You can also update the Front Door with routing rules and backend pool in the portal. Now my endpoint to the backend is emsfrontdoor.azurefd.ner/api/employees. That’s with Front Door.

You can view my next article Front End Application Deployment & Authenticate the Front End with Azure Active Directory.

Thank You!

--

--

No responses yet