Do you know how to create Azure resources?Last updated by Tiago Araújo [SSW] 4 months ago.See history
We've been down this road before where developers had to be taught not to manually create databases and tables. Now, in the cloud world, we're saying the same thing again: Don't manually create Azure resources.
This is the most common and the worst. This is bad because it requires manual effort to reproduce and leaves margin for human error.
- Create resources in Azure and not save a script
Some people half solve the problem by manually creating and saving the script. This is also bad because it’s like eating ice cream and brushing your teeth – it doesn’t solve the health problem.
Tip: Save infrastructure scripts/templates in a folder called 'infra'.
So if you aren't manually creating your Azure resources, what options do you have?
- IaC using F# as a strongly typed DSL
- Generates ARM templates from F#
- Add a very short and readable F# project in your solution
- Tip: The F# solution of scripts should be in a folder called Azure
- Is free and fully supported by Microsoft
- Has 'az' command line integration
- Awesome extension for VS Code to author ARM Bicep files ⭐️
- Under the covers - Compiles into an ARM JSON template for deployment
- Much simpler syntax than ARM JSON
- Handles resource dependencies automatically
- Private Module Registries for publishing versioned and reusable architectures
Tip: If you are assigning any role assignment using bicep, make sure it doesn't exist before. (Using Azure Portal)
Announcement info: Project Bicep – Next Generation ARM Templates
Example Bicep files: Fullstack Webapp made with Bicep
The other option when moving to an automated Infrastructure as Code (IaC) solution is to move to a paid provider like Pulumi or Terraform. These solutions are ideal if you are using multiple cloud providers or if you want to control the software installation as well as the infrastructure.
- Both tools are great and have free tiers available
- Paid tiers provide more benefits for larger teams and helps manage larger infrastructure solutions
Terraform uses HashiCorp Configuration Language HCL
- like YAML but much more powerful
- Pulumi uses real code (C#, TypeScript, Go, and Python) as infrastructure rather than JSON/YAML
Tip: After you’ve made your changes, don’t forget to visualize your new resources.