Last active
April 21, 2021 14:34
-
-
Save stefanstranger/cccb9e1ee9a2c5f084b342dc6b011f92 to your computer and use it in GitHub Desktop.
Decompiling Bicep file to PSArm object
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
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