.NET Core - Azure Infrastructure

Overview

This page present the high level design of the reference implementation of the .NET Core Stacks REST API with CQRS.

This page assumes that the core infrastructure has already been provisioned. Instructions and additional information on the core infrastructure can be found here

Both the diagram and resource list below are for a single environment.

Diagram

Azure .NET API Infrastructure

Resource List

ResourceDescription
Resource Group - Core*Used to logically group core infrastructure
AKS*Azure Kubernetes Service
Public DNS RecordDNS record pointing Ingress (via application gateway* and internal load balancer*)
ACR*Azure Container Registry
Namespace: {env}-apiKubernetes namespace for the environment
IngressKubernetes Ingress to handle routing to Service
ServiceKubernetes Service to handle routing to Deployment Pods
DeploymentKubernetes Deployment for managing Pods
Resource Group - APIUsed to logically group API specific infrastructure
Cosmos DBAzure managed NoSQL database

* Resource is created by the core infrastructure deployment.

Deploying

Pipelines

The following pipelines are currently supported for automating the deployment:

Running Locally

Currently, vars.tf and provider configuration is not automatically updated. Future iterations will include this.

The safest way to run and maintain this locally is to rely on Docker and environment variables as that is the way the pipeline will trigger the executions of Terraform.

Sample commands with example environment vars:

# Navigate to the infra directory
cd ${YOUR_DIRECTORY_PATH}/deploy/azure/app
# Run Amido Terraform Docker container
docker run -v $(pwd):/usr/data --rm -it amidostacks/ci-tf:0.0.4 /bin/bash
###########################################################################
# All commands from this point should be executed in the Docker container #
###########################################################################
# Navigate to /usr/data directory
cd /usr/data
# Export Azure Credentials. Replace the example values.
export ARM_CLIENT_ID=1111-2222-3333-444 \
ARM_CLIENT_SECRET=1111-2222-3333-4444 \
ARM_SUBSCRIPTION_ID=1111-2222-3333-444 \
ARM_TENANT_ID=1111-2222-3333-444
# Export Terraform variables. Replace the example values.
export TF_VAR_name_company=amido \
TF_VAR_name_project=example \
TF_VAR_name_domain=menu-api \
TF_VAR_name_environment=dev \
TF_VAR_core_resource_group=amido-example-nonprod-uks-core \
TF_VAR_resource_group_location=uksouth \
TF_VAR_app_gateway_frontend_ip_name=amido-example-nonprod-uks-core \
TF_VAR_create_dns_record=true \
TF_VAR_dns_zone_name=nonprod.amidostacks.com \
TF_VAR_dns_record=dev-menu-api \
TF_VAR_internal_dns_zone_name=nonprod.amidostacks.internal \
TF_VAR_create_cosmosdb=true \
TF_VAR_cosmosdb_sql_container=Menu \
TF_VAR_cosmosdb_sql_container_partition_key=/id \
TF_VAR_cosmosdb_kind=GlobalDocumentDB \
TF_VAR_cosmosdb_offer_type=Standard \
TF_VAR_app_insights_name=amido-example-nonprod-uks-core
# Initial Terraform. Replace the example values.
terraform init \
-backend-config="resource_group_name=amido-stacks-terraform" \
-backend-config="storage_account_name=amidostacksterraform" \
-backend-config="container_name=tfstate" \
-backend-config="key=example-menu-api"
# Select or create the "dev" workspace.
terraform workspace select dev || terraform workspace new dev
# Check the plan matches your expected changes.
terraform plan