DEV Community

Cover image for Let's explore Azure Functions & Azure Cosmos DB - Part 1
Bervianto Leo Pratama
Bervianto Leo Pratama

Posted on

Let's explore Azure Functions & Azure Cosmos DB - Part 1

Hi everyone,

I want to learn more about cloud, cloud services, cloud computing, etc. That is why I write up this one. I want to explore more Azure Functions. This is not a tutorial, I just want to take note some problems and what went well when I was exploring the Azure Functions. You want to learn more about Azure Cosmos DB, you can check here


Azure Functions Problems

ClaimsPrincipal is not filled by Username/Email

This problem took me many days to find the solution. Until now, I still can't figure out why. So, I take workaround. My workaround are read the header X-MS-CLIENT-PRINCIPAL-NAME and activate the Easy Auth. This is a disadvantage, I can't know if my solution works. I need to deploy to the Azure Functions and call it with my client code. I want to minimize test directly to "production" when heavy development time, but I don't have many choice now.

Azure Cosmos DB Problems

The Error Come from EF CosmosDB Provider Little Bit Hard to Understand

As a newcomer at CosmosDB, I think the error little bit hard to understand. When I am not setting up the Container, they only said 404. It is hard for me to know the error context.

Some notes:

  • Database Name: You will set up this at UseCosmos. This is same with database in CosmosDb.

Database Name

  • Collection: When use define DbContext, your DbContext will become Collection. So you need to create it or setup it before.


Can't create Azure Cosmos DB because high demand?

I don't understand for this. Is it really because high demand? I want to provision Azure Cosmos DB at Southeast Asia, but it is always said high demand. So I take workaround to use Azure Cosmos DB free and use different region. It is have different region and quite far from my place. It has huge delay in my application because of this. Anyway, do you want to try Azure Cosmos DB? You can check here.

Show Case

I have some videos when I was exploring the Azure Functions and Azure Cosmos DB. Here we are,

  • Deploy Azure Functions using Visual Studio 2022

  • Create Azure Cosmos Db Free

  • Setup Azure Cosmos Db

  • Setup Easy Auth Azure Functions


GitHub logo bervProject / azure-function-example

Azure Function Example in .NET


Azure Function Example in .NET

Directory Structure

  • azure-functions: Root directory for Azure Functions of Backend that will be hosted at Azure Functions. Using .NET 6.
  • azure-function-client: Root directory for client to consume Azure Functions and will be hosted at Azure Static Web App Service. Using React.js.
  • ToDo.Web: Root directory that consume the Backend from Azure Functions, run as Web App and will be hosted at Azure Web App Service. Using .NET 6.


Please see at




Bervianto Leo Pratama

Next Part

For the next part, I will tell more about the Azure Static Web Apps and deploy the client into there. We will consume the azure functions and use msal as our authentication client.

Thank you

Thanks GIF

Top comments (0)