DEV Community

DongAn
DongAn

Posted on

Resolve errors in "Build flexible Bicep files by using conditions and loops - Unit 5_Exercise."

Several issues lead to errors in Unit 5, "Exercise - Deploy multiple resources by using loops," within the "Build flexible Bicep files by using conditions and loops" module on Microsoft Learn. Primarily, the main.bicep file lacks an environmentName parameter. This omission prevents control over the deployment environment, limiting the exercise to the creation of only the SQL server and SQL database, even when following the provided steps.

You can add the following snippet to your main.bicep file to solve the problem.

Another issue that can cause deployment failure is related to the Microsoft Learn sandbox. Due to unknown issues, attempting to deploy resources via Bicep code in the sandbox repeatedly led to my temporary account being deactivated. Even with remaining usage attempts, and after waiting for four hours to create a new account, the problem persisted. Therefore, for this exercise, it may be necessary to use an Azure pay-as-you-go account to complete the task.

Managing the environment with Azure CLI:
az deployment group create --resource-group Your-RG-Name --name main --template-file main.bicep --parameters environmentName=Production

After a successful deployment, your resource group should include the following resources:

Top comments (0)