---
title: "Azure Deployment"
description: "Deploy TraceRTM on Microsoft Azure"
keywords: [azure, microsoft, app service, sql database, deployment]
---

# Azure Deployment

Deploy TraceRTM on Microsoft Azure.

## Architecture

### Recommended Setup

```
Azure Application Gateway
    ↓
App Service (API)
    ↓
Azure Database for PostgreSQL (Database)
    ↓
Azure Cache for Redis (Cache)
```

## App Service Deployment

### Create App Service Plan

```bash
az appservice plan create \
  --name tracertm-plan \
  --resource-group tracertm-rg \
  --sku B1 \
  --is-linux
```

### Create Web App

```bash
az webapp create \
  --resource-group tracertm-rg \
  --plan tracertm-plan \
  --name tracertm-api \
  --runtime "PYTHON:3.12"
```

### Configure Environment Variables

```bash
az webapp config appsettings set \
  --resource-group tracertm-rg \
  --name tracertm-api \
  --settings \
    DATABASE_URL="..." \
    REDIS_URL="..." \
    SECRET_KEY="..."
```

### Deploy Application

```bash
# Deploy from local
az webapp deployment source config-zip \
  --resource-group tracertm-rg \
  --name tracertm-api \
  --src app.zip

# Or deploy from Git
az webapp deployment source config \
  --resource-group tracertm-rg \
  --name tracertm-api \
  --repo-url https://github.com/user/tracertm \
  --branch main \
  --manual-integration
```

## Azure Database for PostgreSQL

### Create Server

```bash
az postgres server create \
  --resource-group tracertm-rg \
  --name tracertm-db \
  --location eastus \
  --admin-user postgres \
  --admin-password YourPassword123 \
  --sku-name GP_Gen5_2 \
  --version 14
```

### Create Database

```bash
az postgres db create \
  --resource-group tracertm-rg \
  --server-name tracertm-db \
  --name tracertm
```

### Connection String

```bash
DATABASE_URL=postgresql://postgres:password@tracertm-db.postgres.database.azure.com:5432/tracertm?sslmode=require
```

## Azure Cache for Redis

### Create Redis Cache

```bash
az redis create \
  --resource-group tracertm-rg \
  --name tracertm-redis \
  --location eastus \
  --sku Basic \
  --vm-size c0
```

### Get Connection String

```bash
az redis list-keys \
  --resource-group tracertm-rg \
  --name tracertm-redis

REDIS_URL=redis://:KEY@tracertm-redis.redis.cache.windows.net:6380?ssl=true
```

## Application Gateway

### Create Gateway

```bash
az network application-gateway create \
  --resource-group tracertm-rg \
  --name tracertm-gateway \
  --location eastus \
  --capacity 2 \
  --sku Standard_v2 \
  --public-ip-address tracertm-ip
```

## Key Vault

### Store Secrets

```bash
# Create Key Vault
az keyvault create \
  --name tracertm-vault \
  --resource-group tracertm-rg

# Store secret
az keyvault secret set \
  --vault-name tracertm-vault \
  --name database-url \
  --value "postgresql://..."
```

### Access from App Service

```bash
az webapp config appsettings set \
  --resource-group tracertm-rg \
  --name tracertm-api \
  --settings \
    "@Microsoft.KeyVault(SecretUri=https://tracertm-vault.vault.azure.net/secrets/database-url/)"
```

## Monitoring

### Application Insights

```bash
# Create Application Insights
az monitor app-insights component create \
  --app tracertm-insights \
  --location eastus \
  --resource-group tracertm-rg

# Connect to App Service
az webapp config appsettings set \
  --resource-group tracertm-rg \
  --name tracertm-api \
  --settings \
    APPINSIGHTS_INSTRUMENTATIONKEY="..."
```

## Related Documentation

- [Cloud Platforms](./03-cloud-platforms) - Cloud overview
- [Docker Deployment](./01-docker-deployment) - Docker setup
