Add subscription-scoped Bicep demo for Windows VM stack#12
Add subscription-scoped Bicep demo for Windows VM stack#12
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a demo Azure VM stack under infra/bicep/ using a subscription-scoped entrypoint that creates a resource group and deploys a resource-group–scoped module to provision networking + a Windows Server VM in Sweden Central.
Changes:
- Added
infra/bicep/main.bicep(subscription scope) to create the RG and invoke the VM stack module. - Added
infra/bicep/modules/vmStack.bicepto deploy VNet/Subnet/NSG/Public IP/NIC and a Windows Server VM. - Added a sample parameter file and deployment documentation (
main.bicepparam,README.md).
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| infra/bicep/main.bicep | Subscription-scope entrypoint that creates the RG and calls the VM stack module. |
| infra/bicep/modules/vmStack.bicep | Resource-group module that defines the networking resources and Windows VM. |
| infra/bicep/main.bicepparam | Sample parameter values to drive the deployment. |
| infra/bicep/README.md | Local build + Azure validate/deploy instructions for the demo stack. |
| osProfile: { | ||
| computerName: vmName | ||
| adminUsername: adminUsername | ||
| adminPassword: adminPassword |
There was a problem hiding this comment.
osProfile.computerName for Windows VMs must be 15 characters or fewer. vmName is derived from demo${uniqueString(...)}-vm and will exceed that limit, which will cause the deployment to fail. Introduce a separate, shorter computerName value (e.g., a truncated/sanitized version) and keep the Azure resource name as-is if desired.
| resource publicIp 'Microsoft.Network/publicIPAddresses@2023-11-01' = { | ||
| name: publicIpName | ||
| location: location | ||
| sku: { | ||
| name: 'Basic' | ||
| } | ||
| properties: { | ||
| publicIPAllocationMethod: 'Dynamic' | ||
| } |
There was a problem hiding this comment.
The public IP is created as sku: Basic with publicIPAllocationMethod: Dynamic. For new/long-lived demos this is brittle (and in some subscriptions/regions Basic is no longer permitted); Standard + Static is the recommended SKU and avoids unexpected IP changes.
| param resourceGroupName = 'demo-bicep-rg' | ||
| param location = 'swedencentral' | ||
| param adminUsername = 'azureuser' | ||
| param adminPassword = '<enter-strong-password>' |
There was a problem hiding this comment.
adminPassword is marked @secure() in main.bicep, but the .bicepparam file still includes an adminPassword entry. Even with a placeholder, this pattern encourages putting secrets into source-controlled param files and can lead to accidental check-ins of real passwords. Prefer removing adminPassword from main.bicepparam and supplying it only via CLI/secure mechanisms (as already shown in the README).
| param adminPassword = '<enter-strong-password>' |
| Subscription-scoped Bicep template that provisions a low-cost Windows Server VM with a virtual network, subnet, NSG, NIC, public IP, and managed OS disk in Sweden Central. | ||
|
|
||
| ## Files | ||
| - `main.bicep` – subscription-scope deployment that creates the resource group, networking, public IP, NIC, and VM |
There was a problem hiding this comment.
The README states main.bicep creates the networking/public IP/NIC/VM, but those resources are actually created in modules/vmStack.bicep (with main.bicep only creating the RG and invoking the module). Updating this description will prevent confusion when readers browse the files.
| - `main.bicep` – subscription-scope deployment that creates the resource group, networking, public IP, NIC, and VM | |
| - `main.bicep` – subscription-scope deployment that creates the resource group and invokes the `modules/vmStack.bicep` module for the networking, public IP, NIC, and VM |
Provision a demo-friendly Azure VM stack in Sweden Central via Bicep, creating the RG, networking, NSG, NIC, public IP, and Windows Server VM with low-cost defaults and deployment guidance.
infra/bicep/main.bicepcreates the resource group and calls a resource-group–scoped VM stack module; parameters include location, VM size, image SKU, and secure admin credentials.infra/bicep/modules/vmStack.bicepbuilds VNet/Subnet, NSG, public IP, NIC, and a Standard_B2s Windows Server VM with managed OS disk.infra/bicep/main.bicepparamsample (placeholder password) and expandedinfra/bicep/README.mdwith validate/deploy commands.Example:
Original prompt