Reputation: 13
so Im pretty new to VS code and JSON/Bicep templates to deploy resources in Azure. Im trying to deploy a VM inside one resource group and within that RG, a vNet already created too.
the problem im having it with this:
param adminUsername string
@minLength(12)
@secure()
param adminPassword string
When Im trying to deploy the biceps its telling me that there is any Parameter file defined so it cannot find the value for adminusername or adminpassword. I created a JSON file with the parameters:
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"adminUsername": {
"value": "XXXXXXX"
},
"adminPassword": {
"value": "XXXXXXXXX"
},
"dnsLabelPrefix": {
"value": "XXXXX"
}
}
}
Now, how can I link in VS Code this Bicep template with this Parameter file so when I right click on the name it will start the deploy in my tenant?
I've read that there is a PS command to make it possible, for example:
"-TemplateParameterFile "/home/lakshmi/module.parameters.json""
where exactly is "/home..." folder? Is there a way to deploy the parameters+bicep template without PS?
Thanks!
I've already checked here but I find it confusing since still dont fully understand it:
Upvotes: 0
Views: 1080
Reputation: 4024
There are multiple ways of deploying your Bicep templates. You can use;
Azure PowerShell with New-AzResourceGroupDeployment
Command
By providing the name of the resource group, template file, and the parameter file. Example is give below;
New-AzResourceGroupDeployment -ResourceGroupName 'my-resource-group' -TemplateFile .\main.bicep -TemplateParameterFile .\param.json
This command is run from the directory where the main.bicep
and param.json
files are located. This will deploy your bicep template to a Resource group. You can even deploy at the Azure Subscription level but don't worry about that at the moment.
If you want to deploy the bicep file from Visual Studio Code, you need to have couple of extensions installed. Install the following extensions
Once you have these 2 extensions installed, you can right-click on the bicep file and select the Deploy Bicep file...
option. You will be asked to login to Azure and a few more inputs to gather a name for the deployment and you will be able to browse for the parameter file as well.
Follow this documentation link for step by step instructions. https://learn.microsoft.com/en-us/azure/azure-resource-manager/bicep/deploy-vscode
Upvotes: 1