# Azure Resource Providers - Required for The Order

**Last Updated**: 2025-01-27  
**Default Region**: West Europe (westeurope)  
**Policy**: No US Commercial or Government regions

---

## Required Resource Providers

The following Azure Resource Providers must be registered in your subscription before deploying The Order infrastructure:

### Core Infrastructure Providers

1. **Microsoft.ContainerService**
   - **Purpose**: Azure Kubernetes Service (AKS)
   - **Required For**: Kubernetes cluster deployment
   - **Registration**: Required

2. **Microsoft.KeyVault**
   - **Purpose**: Azure Key Vault for secrets management
   - **Required For**: Secure storage of secrets, certificates, keys
   - **Registration**: Required

3. **Microsoft.Storage**
   - **Purpose**: Azure Storage Accounts
   - **Required For**: Object storage, Terraform state backend
   - **Registration**: Required

4. **Microsoft.Network**
   - **Purpose**: Virtual Networks, Load Balancers, Application Gateway
   - **Required For**: Networking infrastructure
   - **Registration**: Required

5. **Microsoft.Compute**
   - **Purpose**: Virtual Machines, VM Scale Sets
   - **Required For**: AKS node pools, compute resources
   - **Registration**: Required

### Database & Storage Providers

6. **Microsoft.DBforPostgreSQL**
   - **Purpose**: Azure Database for PostgreSQL
   - **Required For**: Primary database service
   - **Registration**: Required

7. **Microsoft.ContainerRegistry**
   - **Purpose**: Azure Container Registry (ACR)
   - **Required For**: Container image storage and management
   - **Registration**: Required

### Identity & Access Providers

8. **Microsoft.ManagedIdentity**
   - **Purpose**: Azure Managed Identities
   - **Required For**: Service-to-service authentication without secrets
   - **Registration**: Required

9. **Microsoft.Authorization**
   - **Purpose**: Role-Based Access Control (RBAC)
   - **Required For**: Access control and permissions
   - **Registration**: Required

### Monitoring & Observability Providers

10. **Microsoft.Insights**
    - **Purpose**: Application Insights, Azure Monitor
    - **Required For**: Application monitoring and metrics
    - **Registration**: Required

11. **Microsoft.OperationalInsights**
    - **Purpose**: Log Analytics Workspaces
    - **Required For**: Centralized logging and log analysis
    - **Registration**: Required

### Workflow & Integration Providers

12. **Microsoft.Logic**
    - **Purpose**: Azure Logic Apps
    - **Required For**: Workflow orchestration (optional but recommended)
    - **Registration**: Required if using Logic Apps

### Resource Management Providers

13. **Microsoft.Resources**
    - **Purpose**: Azure Resource Manager
    - **Required For**: Resource group management, deployments
    - **Registration**: Required (usually pre-registered)

---

## Preview Features

Currently, no preview features are required. If Microsoft Entra VerifiedID requires preview features, they will be documented here.

---

## Registration Status

### Check Registration Status

```bash
# Check all required providers
./infra/scripts/azure-register-providers.sh

# Or check individually
az provider show --namespace Microsoft.ContainerService
```

### Register All Providers

```bash
# Run the registration script
./infra/scripts/azure-register-providers.sh
```

### Manual Registration

If you need to register providers manually:

```bash
# Register a single provider
az provider register --namespace Microsoft.ContainerService

# Register all providers
for provider in \
  Microsoft.ContainerService \
  Microsoft.KeyVault \
  Microsoft.Storage \
  Microsoft.Network \
  Microsoft.Compute \
  Microsoft.DBforPostgreSQL \
  Microsoft.ContainerRegistry \
  Microsoft.ManagedIdentity \
  Microsoft.Insights \
  Microsoft.Logic \
  Microsoft.OperationalInsights \
  Microsoft.Authorization \
  Microsoft.Resources; do
  az provider register --namespace "${provider}" --wait
done
```

---

## Registration Verification

After registration, verify all providers are registered:

```bash
# Check registration status
az provider list --query "[?contains(namespace, 'Microsoft')].{Namespace:namespace, Status:registrationState}" -o table
```

All providers should show `Registered` status.

---

## Regional Availability

**Important**: The Order uses **West Europe (westeurope)** as the default region. US Commercial and Government regions are **not used**.

### Recommended Regions

- **Primary**: `westeurope` (West Europe)
- **Secondary**: `northeurope` (North Europe)
- **UK**: `uksouth` (UK South)
- **Switzerland**: `switzerlandnorth` (Switzerland North)
- **Norway**: `norwayeast` (Norway East)

### Check Regional Availability

Some resource providers may not be available in all regions. Check availability:

```bash
# Check AKS availability
az provider show --namespace Microsoft.ContainerService --query "resourceTypes[?resourceType=='managedClusters'].locations" -o table

# Check PostgreSQL availability
az provider show --namespace Microsoft.DBforPostgreSQL --query "resourceTypes[?resourceType=='servers'].locations" -o table
```

---

## Troubleshooting

### Provider Registration Fails

1. **Check Subscription Permissions**
   ```bash
   az account show
   az role assignment list --assignee $(az account show --query user.name -o tsv)
   ```

2. **Check Subscription State**
   ```bash
   az account show --query state
   ```
   Must be `Enabled`

3. **Wait for Registration**
   - Some providers take 5-10 minutes to register
   - Use `--wait` flag or check status periodically

### Provider Not Available in Region

1. **Check Regional Availability**
   ```bash
   az provider show --namespace <ProviderName> --query "resourceTypes[?resourceType=='<ResourceType>'].locations"
   ```

2. **Use Alternative Region**
   - Consider using `northeurope` or `uksouth` as alternatives

### Quota Issues

1. **Check Quotas**
   ```bash
   ./infra/scripts/azure-check-quotas.sh
   ```

2. **Request Quota Increase**
   - Go to Azure Portal → Subscriptions → Usage + quotas
   - Request increase for required resources

---

## Next Steps

After registering all resource providers:

1. ✅ Run `./infra/scripts/azure-setup.sh` to complete Azure setup
2. ✅ Check quotas: `./infra/scripts/azure-check-quotas.sh`
3. ✅ Proceed with Terraform initialization: `terraform init`
4. ✅ Plan infrastructure: `terraform plan`
5. ✅ Deploy infrastructure: `terraform apply`

---

## References

- [Azure Resource Provider Registration](https://docs.microsoft.com/en-us/azure/azure-resource-manager/management/resource-providers-and-types)
- [Azure CLI Provider Commands](https://docs.microsoft.com/en-us/cli/azure/provider)
- [Azure Regional Availability](https://azure.microsoft.com/en-us/global-infrastructure/services/)

