My articles about the Microsoft Azure cloud

Integrate a Web App with a CosmosDB database using a Virtual Network Service Endpoint in Azure

Consider the following real-life application scenario. Your Web App (Azure App Service) accesses a CosmosDB instance to read data. Your users access the web application from its UI, and you want to ensure they cannot directly access the CosmosDB instance using its public URL.

In this article, you will learn:

  • How to use a System Managed Identity and RBAC roles to access your CosmosDB instance from your Web App
  • How to integrate your Web App and your CosmosDB with an Azure Virtual Network
  • How to create a Service Endpoint to allow only the Virtual Network to access CosmosDB
  • All the necessary az CLI commands to complete the tutorial, without using the Azure Portal UI :)
Read the complete article

Deploy a .NET & Angular application to an Azure App Service with multiple environments using an Azure Pipeline and Bicep

In this article, I will show you a full tutorial on how to create a .NET application using Angular for the frontend and deploy this application with Azure DevOps pipelines on multiple App Service environments.

You are going to learn:

  • How to use pipeline templates to simplify the structure of our pipeline
  • How to use multiple stages to split semantically different jobs
  • How to use multiple Azure environments by elevating the power of a for loop in the pipeline
  • How to use Bicep for setting up the needed Azure infrastructure
  • How to deploy the application on an Azure App Service by using different deployment slots

You can find the code for this tutorial on my GitHub account.

Read the complete article

Use the TableOutput attribute to write in a Storage Account from your Function by using a Managed Identity

Consider the following scenario in Azure:

  • We want to create a new Azure Function triggered by an HTTP request containing some data.
  • We want to write this data as new entities into a Storage Table.
  • We want to avoid storing any connection string in your code and instead use an Entra ID Managed Identity.
  • We want to avoid writing any specific code by using the SDK for accessing the Table.

The TableOutputAttribute comes to the rescue. Let us see how.

Read the complete article

Access Azure Key Vault secrets using a Service Principle with certificate within an Azure DevOps pipeline

Azure Key Vault is a cloud service that provides secure storage for secrets, keys, and certificates of your applications. Integrating Key Vault with Azure DevOps pipelines enhances security by managing sensitive information efficiently.

This article will guide you through the process of accessing secrets from an Azure Key Vault using a Service Principal with a certificate within an Azure pipeline. We will start for the very first steps of creating all the needed resources in Azure, before going back to Azure DevOps. For training reasons, we will perform all the configuration steps with CLI commands, avoiding the Azure Portal UI.

Read the complete article

How to configure your Docker build to run on both Visual Studio and on Azure pipelines

When working with Docker in Visual Studio, the default behavior of the IDE is to place the Dockerfile at the project level. However, if your solution has multiple projects and you want to achieve easier integration of the Dockerfile into your Azure pipelines, then you might want to move the file to the solution level. Let us see how to achieve this task.

Read the complete article

Create an Event Grid and access it via a Web App with a common User Managed Identity. An Azure scenario explained.

In this article, we’ll walk through the steps to create a User Managed Identity, and use it to authenticate between Azure Resources, create events from an .NET Azure App Service and push them into an Event Grid topic. All this will be done using only Azure CLI commands. But first of all lets see why a Managed Identity should be used in the first place.

Read the complete article

The way to fix the You don’t appear to have an active Azure subscription error in Azure DevOps

I recently wanted to configure the CI/CD process in Azure DevOps of a new application I created and wire it with my Azure account so that the application will be deployed on an App Service. A missing user permission in the project settings was the problem. Lets see the steps to solve the error.

Read the complete article

Understanding and Resolving the BCP001 Error in Bicep

Bicep, a domain-specific language (DSL) for deploying Azure resources, simplifies the process of writing infrastructure as code. However, like any programming language, it has its own set of rules and syntax that must be followed. One common error that developers encounter is the BCP001 error, which occurs when Bicep encounters an unrecognized token.

Read the complete article

Understand iterator methods and the yield keyword in C# with the help of examples

An iterator in C# is a method that utilizes the yield keyword to return elements one at a time to the caller. Such methods are very useful for traversing collections, without needing to create an intermediate collection inside the method for storing results.

This article will help you understand how to use yield by using practical examples.

Read the complete article

How to create a Nuget Package of your .NET code and host it in a private Azure DevOps Feed

In this tutorial we are going to see how to set up your .NET code as a Nuget Package and host this package on an private Azure DevOps Feed. You can then use the Package on other .NET projects.

Read the complete article

How to define and use Application Settings in your Azure Functions

As it is stated in the Azure Portal Application settings are encrypted at rest and transmitted over an encrypted channel. You can choose to display them in plain text in your browser by using the controls below. Application Settings are exposed as environment variables for access by your application at runtime.

Storing sensitive data as application settings is preferred over having them in plain text in your code. In this article we are going to see how to define them in your Azure Portal, how to integrate them in your Function-code and how to give them values when you are debugging your Functions locally.

Read the complete article

How to update your Azure Functions from version 2 (V2) to version 3 (V3)

Here is a small and quick article about how to perform the update in your C# project that contains the Azure Functions of your application

Read the complete article

How to fix the "Unable to retrieve child resources. This request is not authorized to perform this operation" error on Azure Storage Explorer

If you use the Azure cloud for hosting your application, chances are that you are also using a Storage Account and you are accessing its content via the Azure Storage Explorer tool.

If you are all of the sudden get the Unable to retrieve child resources. This request is not authorized to perform this operation error, then a possible reason for that is that the IP you are using to connect to Azure is not yet white-listed

Read the complete article

Secure your Azure Functions while in development

Azure Functions are compact and lightweight chunks of code hosted in Azure cloud and can be accessed via HTTP. Since these functions might access sensible data of your application, you want a safe way to call them.

When you are in the development phase, you can use the Host Keys which is a way of authenticating yourself when calling an Azure Function.

When in production, you will have to change to App Service Authentication, since the Host Keys should not be stored in the client’s machines.

Read the complete article

Get extra log information about errors happening on your Azure App Service

When you run your application on an Azure App Service there will the case where you want some extra logging information when errors happen. A fast way to get the exact error and its stacktrace in your application is to activate the Application Logging. To activate it, you have to do the following simple steps:

Read the complete article

Implement a static Vue app and deploy it on Azure using CI/CD. Part 2, Continuous Delivery

In the previous article we focused on building the Continuous Integration Pipeline of our hello-world Vue app.

In Part 2 we are going to do the steps for deploying the result of the CI Pipeline to Azure. From there our static website is going to be visible to the rest of the world.

Here are the steps you will have to take:

Read the complete article

Implement a static Vue app and deploy it on Azure using CI/CD. Part 1, Continuous Integration

While I have some extra free time because of the Corona virus outbreak, I decided to experiment with Vue and build a small static HTML Hello-World application for getting to know the framework better. The website contains no backend code.

The article focuses on how to automate the Build and Deploy process of our small application. I will try to clarify the steps needed till our static website is visible through an Azure URL.

In this article I will skip the Vue logic of my app and focus solely on the DevOps tasks that have to be made in Azure DevOps. Our static website will then be deployed on an Azure Storage Container. The article focuses on Windows users.

Read the complete article

Create an Azure Function with Storage Table in Visual Studio Code

Back in 2017, I wrote an article about how to program an Azure Function in Visual Studio. With the current article I want to give the current state of creating Functions, this time in Visual Studio Code.

We are going to create a GET Function that retrieves all the rows from an Azure Storage Table and returns them the caller.

Here are the steps from scratch:

Read the complete article

Create a real-life example (Function, Service Bus Queue, Storage Table) of an Azure Logic App. A step to step example.

Some time ago I wrote an article with an example of an Azure Function which I used in my applications. With the current article I want to present you another real-life example of using different Azure Services and combining them together in a Logic App.

A Logic App represents a workflow of steps that are defined to be done in a sequential or in a parallel manner.

Our scenario contains a company which owns an eshop. We are going to build a workflow for getting customer orders, pushing them into a queue for almost-real-time process (A queue is a good way to balance load of large number of requests in your servers), retrieving them back, storing them in a storage table and informing the user about her order with an email. The most important thing, we are going to develop all the steps inside the Azure Portal; the use of Visual Studio is optional.

After we finish with the creation of our Logic App, we are going to have the following workflow:

Read the complete article

The reason behind the identifier could not be resolved error in your CosmosDB queries

When writing SQL queries to test them against your CosmosDB collections, you might encounter the following error message:

Identifier XXX could not be resolved.

Here, XXX is the name of a property inside your collection. For example, consider the following query:

Read the complete article

How to fix the 'Could not load file or assembly Newtonsoft.Json, Version=7.0.0.0...' error when creating a REST API Client for Azure in Visual Studio

The last few days I have been experimenting with the different types of App Services that the Azure platform provides. One very interesting combination of app services is a ASP.NET MVC client (Azure Web app) or a WebAPI (Azure API app) which acts as the middleware between a JavaScript client and an internal “business” WebAPI (Azure API app). The architecture looks like this:

Read the complete article

A real world Azure Function example that logs client errors in a Storage Table

Today I invested some time into getting deeper to the topic of Azure Functions. Together with the new microservices architecture, new ways of doing business logic arise. Azure Functions are small chunks of code that run in a “serverless” (you do not care about allocating new hardware resources, even when the requests to the function raise) environment and each of them is meant to do one specific job.

Apart from the great examples and templates with Functions that you can find inside the Azure Portal, I tried to think of some use cases that I would use an Azure Function for a web application and I came up with the following one:

Read the complete article

Store .NET objects inside an Azure Table Storage and then retrieve them back in their original type

Non-relational databases are becoming more and more popular as a solution for storing your data. Cloud solutions like Microsoft Azure also get more popular with every day.

Currently Azure supports two types of “NoSQL” databases in the Azure portal. The one is DocumentDB (the NoSQL option in the main menu of the portal) and the other is the Table Storage (from the Storage accounts option in main menu). Do not confuse this Table with the tables of a relational database, they are not the same! A detailed analysis of the differences and similarities of the two technologies is beyond the purpose of this article, but we can summarize them to the following points:

Read the complete article

The subscription is not registered for the resource type components in the location Central US error when creating a new Azure Web App in Visual Studio

With the Azure cloud solution from Microsoft we can create a new web application with Visual Studio, deploy it as a Azure Web App and “go live” in only few minutes.

I recently was faced with the “The subscription is not registered for the resource type ‘components’ in the location ‘Central US’” error when I was trying to publish my new web application to a Website (or a Web App) in Azure. Either starting from scratch with a web project and doing the mapping or by using the Publish option of an already created project, I was getting the same error. Visual Studio tried to publish the application to Windows Azure with no success.

Read the complete article