Azure / Azure/bicep

Decompiler is unable to convert templates containing KeyVault secret reference parameters

Open
#4,374 3 comments 2 reactions 0 assignees View on GitHub
enhancement story: decompiler
Dominant language
Bicep
Stars
3.6k
Forks
830
Avg merge
1d 21m
Merged PRs (30d)
79

Description

I am trying to decompile an arm-template but I get the error:
`Decompilation failed with fatal error "Value cannot be null. (Parameter 'value')"`

```
az bicep version
Bicep CLI version 0.4.613 (d826ce8411)
```

This is the arm template:

```json
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"integrationServiceEnvironmentId":{
"type": "string",
"metadata": {
"description": "ResourceId of the ISE"
}
},
"connectionname": {
"type": "string",
"metadata": {
"description": "Name of the connection"
}
},
"serverAddress": {
"type": "string",
"metadata": {
"description": "FTP Server Address"
}
},
"userName": {
"type": "string",
"metadata": {
"description": "User Name"
}
},
"serverPort": {
"type": "int",
"metadata": {
"description": "Provide FTP Server Port"
}
},
"isSSL": {
"type": "bool",
"metadata": {
"description": "Specify if SSL needs to be enabled"
}
},
"isBinaryTransport": {
"type": "bool",
"metadata": {
"description": "Specify if Binary Transport needs to be enabled"
}
},
"disableCertificateValidation": {
"type": "bool",
"metadata": {
"description": "Specify if Certificate Validation needs to be disabled"
}, "defaultValue": "null"
},
"closeConnectionAfterRequestCompletion": {
"type": "bool",
"metadata": {
"description": "Specify if the session should be closed everytime after request completes. Enable if you hit Max Connections limit."
}
},
"keyvaultName": {
"type": "string",
"metadata": {
"description": "Name of the keyvault"
}
},
"keyvaultKey": {
"type": "string",
"metadata": {
"description": "Key of the keyvault secret"
}
}
},
"variables": {
},
"resources": [{
"type": "Microsoft.Resources/deployments",
"apiVersion": "2018-05-01",
"name": "dynamicSecret",
"properties": {
"mode": "Incremental",
"expressionEvaluationOptions": {
"scope": "inner"
},
"parameters": {
"integrationServiceEnvironmentId":{
"value": "[parameters('integrationServiceEnvironmentId')]"
},
"connectionname": {
"value": "[parameters('connectionname')]"
},
"serverAddress": {
"value": "[parameters('serverAddress')]"
},
"userName": {
"value": "[parameters('userName')]"
},
"password": {
"reference": {
"keyVault": {
"id": "[concat(resourceId('Microsoft.KeyVault/vaults', parameters('keyvaultName')))]"
},
"secretName": "[parameters('keyvaultKey')]"
}
},
"serverPort": {
"value": "[parameters('serverPort')]"
},
"isSSL": {
"value": "[parameters('isSSL')]"
},
"isBinaryTransport": {
"value": "[parameters('isBinaryTransport')]"
},
"disableCertificateValidation": {
"value": "[parameters('disableCertificateValidation')]"
},
"closeConnectionAfterRequestCompletion": {
"value": "[parameters('closeConnectionAfterRequestCompletion')]"
}
},

"template": {
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"integrationServiceEnvironmentId": {
"type": "string",
"metadata": {
"description": "ResourceId of the ISE"
}
},
"connectionname": {
"type": "string",
"metadata": {
"description": "Name of the connection"
}
},
"serverAddress": {
"type": "string",
"metadata": {
"description": "FTP Server Address"
}
},
"userName": {
"type": "string",
"metadata": {
"description": "FTP User Name"
}
},
"password": {
"type": "string",
"metadata": {
"description": "FTP password"
}
},
"serverPort": {
"type": "int",
"metadata": {
"description": "Provide FTP Server Port"
}
},
"isSSL": {
"type": "bool",
"metadata": {
"description": "Specify if SSL needs to be enabled"
}
},
"isBinaryTransport": {
"type": "bool",
"metadata": {
"description": "Specify if Binary Transport needs to be enabled"
}
},
"disableCertificateValidation": {
"type": "bool",
"metadata": {
"description": "Specify if Certificate Validation needs to be disabled"
}
},
"closeConnectionAfterRequestCompletion": {
"type": "bool",
"metadata": {
"description": "Specify if the session should be closed everytime after request completes. Enable if you hit Max Connections limit."
}
}
},
"resources": [{
"type": "Microsoft.Web/connections",
"apiVersion": "2016-06-01",
"location": "[resourceGroup().location]",
"name": "[parameters('connectionname')]",
"properties": {
"displayName": "[parameters('connectionname')]",
"customParameterValues": {},
"api": {
"id": "[concat(parameters('integrationServiceEnvironmentId') , '/managedApis/ftp')]"
},
"parameterValues": {
"serverAddress": "[parameters('serverAddress')]",
"userName": "[parameters('userName')]",
"password": "[parameters('password')]",
"serverPort": "[parameters('serverPort')]",
"isSSL": "[parameters('isSSL')]",
"isBinaryTransport": "[parameters('isBinaryTransport')]",
"disableCertificateValidation": "[parameters('disableCertificateValidation')]",
"closeConnectionAfterRequestCompletion": "[parameters('closeConnectionAfterRequestCompletion')]"
}
}
}],
"outputs": {}
}
}
}]
}

```

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the failure with the supplied ARM template and the reported Bicep CLI version using the decompile command. Trace the decompiler path handling nested deployment parameters and Key Vault references; done means the template no longer fails with a null-value error and produces valid Bicep output.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, json
Domain
cloud, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.