|
| 1 | +# Azure Web Server Example |
| 2 | + |
| 3 | +This example provisions an Azure networking stack with a web server VM using the `azure` provider. |
| 4 | + |
| 5 | +## Architecture |
| 6 | + |
| 7 | +```mermaid |
| 8 | +flowchart LR |
| 9 | + subgraph RG["Resource Group"] |
| 10 | + subgraph VNet["VNet 10.x.0.0/16"] |
| 11 | + Subnet["Subnet\n10.x.1.0/24"] |
| 12 | + NIC["Network\nInterface"] |
| 13 | + Subnet --> NIC |
| 14 | + end |
| 15 | + NSG["NSG\nHTTP:8080\nSSH:22"] --> NIC |
| 16 | + PIP["Public IP"] --> NIC |
| 17 | + NIC --> VM["Web Server\nStandard_DS1_v2\nUbuntu 18.04"] |
| 18 | + VM --> EXT["Custom Script\nExtension"] |
| 19 | + end |
| 20 | + Internet(("Internet")) --> PIP |
| 21 | +``` |
| 22 | + |
| 23 | +## Resources |
| 24 | + |
| 25 | +| # | Resource | Provider Resource | Description | |
| 26 | +|---|----------|-------------------|-------------| |
| 27 | +| 1 | `example_resource_group` | `azure.resources.resource_groups` | Resource group for all stack resources | |
| 28 | +| 2 | `example_vnet` | `azure.network.virtual_networks` | Virtual network with environment-specific CIDR | |
| 29 | +| 3 | `example_subnet` | `azure.network.subnets` | Subnet within the VNet | |
| 30 | +| 4 | `example_public_ip` | `azure.network.public_ip_addresses` | Static public IP for the VM | |
| 31 | +| 5 | `example_nsg` | `azure.network.network_security_groups` | NSG allowing HTTP (8080) and SSH (22 from VNet) | |
| 32 | +| 6 | `example_nic` | `azure.network.network_interfaces` | NIC with subnet, public IP, and NSG | |
| 33 | +| 7 | `example_web_server` | `azure.compute.virtual_machines` | Ubuntu 18.04 VM (Standard_DS1_v2) | |
| 34 | +| 8 | `example_vm_ext` | `azure.compute.virtual_machine_extensions` | Custom script extension to start a web server | |
| 35 | + |
| 36 | +## Environment-Specific CIDR Blocks |
| 37 | + |
| 38 | +| Environment | VNet CIDR | Subnet CIDR | |
| 39 | +|-------------|-----------|-------------| |
| 40 | +| `prd` | 10.0.0.0/16 | 10.0.1.0/24 | |
| 41 | +| `sit` | 10.1.0.0/16 | 10.1.1.0/24 | |
| 42 | +| `dev` | 10.2.0.0/16 | 10.2.1.0/24 | |
| 43 | + |
| 44 | +## Prerequisites |
| 45 | + |
| 46 | +- `stackql-deploy` installed ([releases](https://github.com/stackql/stackql-deploy-rs/releases)) |
| 47 | +- Azure service principal credentials set as environment variables (used for provider authentication): |
| 48 | + |
| 49 | + ```bash |
| 50 | + export AZURE_TENANT_ID=your_tenant_id |
| 51 | + export AZURE_CLIENT_ID=your_client_id |
| 52 | + export AZURE_CLIENT_SECRET=your_client_secret |
| 53 | + ``` |
| 54 | + |
| 55 | +- Stack-specific variables passed via `-e` flags (mapped to manifest globals): |
| 56 | + - `AZURE_SUBSCRIPTION_ID` - your Azure subscription ID |
| 57 | + - `AZURE_VM_ADMIN_PASSWORD` - password for the VM admin user |
| 58 | + |
| 59 | + For more information on authentication, see the [`azure` provider documentation](https://azure.stackql.io/providers/azure). |
| 60 | + |
| 61 | +## Usage |
| 62 | + |
| 63 | +### Deploy |
| 64 | + |
| 65 | +```bash |
| 66 | +target/release/stackql-deploy build examples/azure/azure-web-server dev \ |
| 67 | + -e AZURE_SUBSCRIPTION_ID=${AZURE_SUBSCRIPTION_ID} \ |
| 68 | + -e AZURE_VM_ADMIN_PASSWORD=${AZURE_VM_ADMIN_PASSWORD} |
| 69 | +``` |
| 70 | + |
| 71 | +### Test |
| 72 | + |
| 73 | +```bash |
| 74 | +stackql-deploy test examples/azure/azure-web-server dev \ |
| 75 | + -e AZURE_SUBSCRIPTION_ID=${AZURE_SUBSCRIPTION_ID} \ |
| 76 | + -e AZURE_VM_ADMIN_PASSWORD=${AZURE_VM_ADMIN_PASSWORD} |
| 77 | +``` |
| 78 | + |
| 79 | +### Teardown |
| 80 | + |
| 81 | +```bash |
| 82 | +stackql-deploy teardown examples/azure/azure-web-server dev \ |
| 83 | + -e AZURE_SUBSCRIPTION_ID=${AZURE_SUBSCRIPTION_ID} \ |
| 84 | + -e AZURE_VM_ADMIN_PASSWORD=${AZURE_VM_ADMIN_PASSWORD} |
| 85 | +``` |
| 86 | + |
| 87 | +### Debug mode |
| 88 | + |
| 89 | +```bash |
| 90 | +stackql-deploy build examples/azure/azure-web-server dev \ |
| 91 | + -e AZURE_SUBSCRIPTION_ID=${AZURE_SUBSCRIPTION_ID} \ |
| 92 | + -e AZURE_VM_ADMIN_PASSWORD=${AZURE_VM_ADMIN_PASSWORD} \ |
| 93 | + --log-level debug |
| 94 | +``` |
0 commit comments