Closed lukeuhren closed 3 years ago
Bicep does not have own parameters values file to be used in deployments and therefore decompiler tries to interpret this file as it was a template file, hence the missing type.
Perhaps we could check the schema and warn/block decompilation, but that field is not required.
The other thing I would add is once #858 is done, you will be able to pass the parameters json file with a .bicep file for your deployment. We also have #1278 which will let you link the parameters JSON file while authoring to get deeper validation.
One option is to tighten up the validation we do on the JSON $schema
property, and simply fail decompilation with a better error message if it doesn't match one of the expected template root schemas (e.g. https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#
, https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#
etc).
Thanks for the replies everyone. This clears it up for me as to why it doesn't work. Cheers!
I am also facing same error , can you also please suggest the another approach can be taken for the parameter. json
Well, you can create a bicep param file if you want. I have... here is an example
//this would be C:\temp\biceptemplate-params.bicep //C:\temp\biceptemplate.bicep would be a template for the resource //you do need to set-location usually and then use ../ in the module location
//for example below //../../biceptemplate.bicep
//keyvault params to associate keyvault if needed param kvName string = 'name of keyvault' param subscriptionId string = 'sub id where keyvault resides' param kvResourceGroup string = 'resource group where it resides'
resource kv 'Microsoft.KeyVault/vaults@2019-09-01' existing = { name: kvName scope: resourceGroup(subscriptionId, kvResourceGroup) }
//module for test //module test is the location of the actual bicep template. This is feeding its parameters module test '../../biceptemplate.bicep' = { name: 'test' params: { user: 'testest' diskPassword: kv.getSecret('StorageAccountKey') } }
Then you need to deploy it with something like...
New-AzResourceGroupDeployment -ResourceGroupName "RG" -TemplateFile 'C:\temp\biceptemplate-params.bicep' -Verbose
This will tie both together ....
if you don't have a coding background and this is not easy to understand I am sorry :(
I can try and help if needed
I deployed multiple infrastructures now in BICEP with those param files I mentioned. So I can try and help if needed. Maybe will give Microsoft some ideas.
Thanks @lukeuhren I will try it update if you how it goes, then we surely give idea to the Microsoft :)
Bicep version Bicep CLI version 0.2.328 (a13b032755)
Describe the bug
I use separate parameter files in all my json templates in the repo in devops. Running this from vscode.
This is simply an issue where I can't decompile a .json parameter file to .bicep. I can't see where if it's unsupported right now reading.
Example take a simple parameter file like
try to decompile with .... bicep decompile .\param.json
errors out with ... "Decompilation failed with fatal error "[5:13]: Unable to locate 'type' for parameter 'test'"
Fails on the first parameter on all the files I have tried.
To Reproduce
Create .json file like below as a test parameter file
run the following: bicep decompile filename
it will error out like so ... Decompilation failed with fatal error "[5:13]: Unable to locate 'type' for parameter 'test'"
Additional context If it's in the works and not supported yet all good :)