Skip to content

Instantly share code, notes, and snippets.

@stefanstranger
Last active April 21, 2021 14:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stefanstranger/cccb9e1ee9a2c5f084b342dc6b011f92 to your computer and use it in GitHub Desktop.
Save stefanstranger/cccb9e1ee9a2c5f084b342dc6b011f92 to your computer and use it in GitHub Desktop.
Decompiling Bicep file to PSArm object
<#
Decompiling a bicep file to PSArm
Inspired on issue posted on PSArm Github repo.
https://github.com/PowerShell/PSArm/issues/154
#>
# Decompile ARM template to Bicep file
bicep decompile C:\Users\stefstr\Documents\Github\PSArm\examples\simple-test\template.json
# Convert Bicep file to ARM Template JSON string
[string]$bicep2armjson = (bicep build C:\Users\stefstr\Documents\Github\PSArm\examples\simple-test\template.bicep --stdout)
# Convert Bicep -> ARM Template to PSARM
ConvertFrom-ArmTemplate -Input $bicep2armjson | ConvertTo-PSArm -PassThru
# Store PSArm output in file.
ConvertFrom-ArmTemplate -Input $bicep2armjson | ConvertTo-PSArm -OutFile C:\Users\stefstr\Documents\Github\PSArm\examples\simple-test\template.psarm.ps1 -Force
# Publish ARM Template file. Does not work yet.
$parameters = @{
'StorageAccountName' = 'demo'
'Location' = 'WestEurope'
}
Publish-PSArmTemplate -Path C:\Users\stefstr\Documents\Github\PSArm\examples\simple-test\template.psarm.ps1 -Parameters $Parameters -OutFile template-final.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment