A simple demo to run Nginx on Azure VM.
-
This demo, along with its instructions, scripts, and Bicep template, has been specifically designed to be executed in the
northeurope
region. However, with minimal modifications, you can also try running it in other regions of your choice (the specific steps for doing so are not covered in this context)- 🛠 Azure CLI Installed & Configured - Get help here
- 🛠 Azure Function Core Tools - Get help here
- 🛠 Bicep Installed & Configured - Get help here
- 🛠 [Optional] VS Code & Bicep Extenstions - Get help here
jq
- Get help herebash
or git bash - Get help here
-
-
Get the application code
git clone https://github.com/miztiik/azure-web-server-vm.git cd azure-web-server-vm
-
-
Ensure you have jq, Azure Cli and bicep working
jq --version func --version bicep --version bash --version az account show
-
-
Stack: Main Bicep The params required for the modules are in
params.json
. Modify them as needed. The helper deployment scriptdeploy.sh
will deploy themain.bicep
file. This will create the following resoureces- Resource Group(RG)
- VNet, Subnet & Virtual Machine
- Virtual Machine(Ubuntu)
- Bootstrapped with custom libs using
userData
script.
- Bootstrapped with custom libs using
- User Managed Identity - Identity attached to the VM with the following permissions,
- Monitoring Metrics Publisher
Note - I hacked the template from another repo of mine, so you will see some unused resources(log analytics workspace/queues etc.,). You can safely ignore them, But do remember to clean up your Resource Group to avoid unnecessary costs.
# make deploy sh deployment_scripts/deploy.sh
After successfully deploying the stack, Check the
Resource Groups/Deployments
section for the resources. -
-
-
You can find the web server's public IP address in the output section of the deployment. You can also get it from the Azure Portal.
WEB_SRV_IP="http://20.107.191.133/" curl ${WEB_SRV_IP}
You should see an output like this,
Hello World from miztiik-automation-vm m-web-srv-web-srv-vm-001 10.0.0.4 on Fri May 26 18:53:46 UTC 2023
-
-
In this demonstration, we have shown how to bootstrap a VM with Nginx using Bicep. We have also shown how to use
userData
to bootstrap the VM with custom libs. We have also shown how to useUser Managed Identity
to access Azure resources. -
If you want to destroy all the resources created by the stack, Execute the below command to delete the stack, or you can delete the stack from console as well
- Resources created during Deploying The Solution
- Any other custom resources, you have created for this demo
# Delete from resource group az group delete --name Miztiik_Enterprises_xxx --yes # Follow any on-screen prompt
This is not an exhaustive list, please carry out other necessary steps as maybe applicable to your needs.
This repository aims to show how to Bicep to new developers, Solution Architects & Ops Engineers in Azure.
Thank you for your interest in contributing to our project. Whether it is a bug report, new feature, correction, or additional documentation or solutions, we greatly value feedback and contributions from our community. Start here
Buy me a coffee ☕.
Level: 100