Skip to content

Basic weather API made with c#. Initially, it is tested to be deployed with Azure DevOps

Notifications You must be signed in to change notification settings

christi4n/weatherapi

Repository files navigation

Weather API for Azure DevOps

This project is an API that should be deployed on Azure with Azure DevOps. The concept of IAC is also part of this project with infrastructure provisioning with Terraform.

Create first the base image with Docker

nerdctl build -t chrisnt5/weatherapi .

Once the image is built, we can launch it to test the application.

nerdctl run -p 8080:80 chrisnt5/weatherapi:1.0

The application can be reached at the following url: http://localhost:8080/weatherforecast

Terraform

terraform init
terraform plan

Manual deployment

terraform init
terraform plan
terraform apply

You can reach the application live. Here is for instance my QDNS: http://chrisnt5wa.westeurope.azurecontainer.io/weatherforecast

Service principal

It's like a user account for an application to interact with Azure. We need the following information:

  • ARM_CLIENT_ID
  • ARM_CLIENT_SECRET
  • ARM_TENANT_ID (id of Azure Directory that hosts the client account)
  • ARM_SUBSCRIPTION_ID

You have to register a new application in Azure. Move forward to "Azure Active Directory", "App registrations", "New registration"

See Azure Provider: Authenticating using a Service Principal with a Client Secret

Go then to "Certificates and secrets", "Add a client secret".

Finally, move to Active Directory, IAM. Then, add a role assignment.

Self-hosted agent

You might need to add you own self-hosted agent. See these two tutorials below. Notice that you have more flexibility by using the classic Azure DevOps pipeline wizard.

See Create a self-hosted agent - article one

See Create a self-hosted agent - article two

Make Azure DevOps pipeline knows your secret

Go to pipeline -> Library -> Variable Group to add you four ARM variables and their values. Make sure that the variable ARM_CLIENT_SECRET type is set to secret.

About

Basic weather API made with c#. Initially, it is tested to be deployed with Azure DevOps

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published