.Net Core Web API 3.1 CRUD Operations With Redis Cache and SQL Server on Azure Cloud

Enes Gür
The Startup
Published in
4 min readOct 3, 2020


In this article, I am going to do create Redis Server and SQL Server on Azure Platform and integrate them to .Net Core 3.1 Web API project. After that, I am going to dockerize the project dockerize the project and publish on Azure Cloud Platform.

The project will have five layers which are API, Business, Cache, Data Access, Entities but I will explain only how to create Redis and SQL Server on Azure Platform and integrate them with Net Core app, after that dockerizing and publishing on Azure Cloud Platform. End of the article, I will share GitHub Repo for all details in project.

Creating SQL Server on Azure

When we are in the https://portal.azure.com/#home, we are going to choose “SQL databases” section on the top as you can see in the picture. If there is no this section in there you can find in “Create a resource” section.

Then I set configurations according to myself. If you do not have Server in Azure before, you have to create in “Create new” section and set Server Name, User Name and Password. After set your fields you can press “Review + create” button.

After our SQL Server created, we can see the dashboard.

Creating Redis Server on Azure

Now we are creating Redis Cache on Azure. In portal page, we will choose “Azure Cache for Redis” selection on top.

After that, you are setting configurations according to yourself yourself. Cache Type should be same if you are using free and press “Review + create” button.

After our Redis Server created, we can see the dashboard.

In this page, we should set SSL configuration in “Advanced Settings” which is on the left in menu.

After creating Redis and SQL Server on Azure, we can move to project to integration.

We are setting “appsettings.json” file according to following codes.
You should adjust ConnectionString and Redis Config by your informations. You can get password for Redis in “Primary Key” section in “Keys” in Redis Dashboard on Azure.

And we are setting “BookController.cs”, “BookManager.cs”, “Dapper_BookService.cs” and “RedisCacheService.cs” files according to following codes.

After set our projects files, we are creating “Dockerfile” and write these lines

In the terminal, we will create an image of this project and push it to Docker Hub

(set your docker hub name instead of “aenes”)

-> docker build aenes/crudapp-azure:v1.0 .

-> docker push aenes/crudapp-azure:v1.0

After pushing, last step is waiting us. Publishing our app on Azure Cloud Platform.

We are creating “Container Instances” in “Create a resource” selection.

Then you are setting fields accourding to yours Docker Hub informations.

Then in Networking section, we are defining a DNS name label. I choosed “crudapp-azure”.

Then “Review + create” and wait for our application to be published on Azure Cloud Platform :)

After published, you can test our APIs with queries. For more example of testing APIs and examining full of the project , visit the project repo in GitHub here, Docker Hub here.

Hope to see you in the next post, I wish you healthy days.