Giter Club home page Giter Club logo

psbicep's Introduction

BicepIcon PSBicep - Bicep PowerShell Module

Bicep BicepPreview BicepDownloads

This is the repository for the Bicep PowerShell Module. This is a community project created to enable the features provided by the Bicep CLI in PowerShell. The module provides the same functionality as Bicep CLI, plus some additional features to simplify the Bicep authoring experience.

Commands implemented:

Preview commands:

Note: Starting with version 1.3.0 of the Bicep PowerShell module the cmdlets Build-Bicep and ConvertTo-Bicep uses the assemblies from the official Bicep repository instead of wrapping the Bicep CLI. When new Bicep versions are released there will be a slight delay before the PowerShell module gets tested updated with the latest assemblies. If new functionality is added to Bicep CLI before the PowerShell module supports it, use Install-BicepCLI to install the latest Bicep CLI version and use the CLI while waiting for an updated PowerShell module.

UPCOMING BREAKING CHANGE NOTIFICATION! Future releases of PSBicep will require PowerShell 7.3 or later! Please see Pre-release versions for more info.

Installation

The Bicep PowerShell Module is published to PowerShell Gallery.

Install-Module -Name Bicep

Pre-release versions

To install the latest version in development use the -AllowPrerelease switch.

Install-Module -Name Bicep -AllowPrerelease

Note: If you want to test the latest features before we've release it to PowerShell Gallery, see the Contribution Guide for instructions on how to manually download the dependencies and install the module manually.

Bug report and feature requests

If you find a bug or have an idea for a new feature create an issue in the repo. Please have a look and see if a similar issue is already created before submitting.

Contribution

If you like the Bicep PowerShell module and want to contribute you are very much welcome to do so. Please read our Contribution Guide before you start! ❤

Maintainers

This project is currently maintained by the following coders:

psbicep's People

Contributors

alexaxb avatar asears avatar bjompen avatar c0smin avatar coolhome avatar egullbrandsson avatar johnroos avatar kaloszer avatar matsest avatar nilsson-jens avatar palmemanuel avatar serenevirus avatar simonwahlin avatar stefanivemo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

psbicep's Issues

Tests needed

Is your feature request related to a problem? Please describe.
Automatic tests are needed so they can run during build and before merging pull reqests.

General

  • Validate exported functions (#20)

Public functions

  • ConvertTo-Bicep
  • Get-BicepVersion
  • Install-BicepCLI
  • Build-Bicep
  • Uninstall-BicepCLI
  • Update-BicepCLI
  • Get-BicepApiReference
  • Update-BicepTypes

Private functions

  • CompareBicepVersion
  • GenerateParameterFile
  • InstalledBicepVersion (#41)
  • LatestBicepVersion (#88)
  • TestBicep (#38)
  • ParceBicep
  • WriteBicepDiagnostic
  • WriteErrorStream

Classes

  • BicepResourceProviderCompleter
  • BicepResourceCompleter
  • BicepResourceChildCompleter
  • BicepResourceApiVersionCompleter
  • BicepTypeCompleter

Other

  • Verify helpuri has correct version in the uri

Perhaps individual issues can be created whenever someone starts to work on one of these. In that way its clear who is working on what.

Remove dependency on Bicep CLI by using Bicep assemblies

Is your feature request related to a problem? Please describe.
Current solution wraps Bicep CLI which limits us to the functionality provided by the Bicep CLI. We could create a lot of new features if we use the Bicep assemblies instead.

Describe the solution you'd like
Remove the dependency on Bicep CLI by using Bicep assemblies. This means re-writing the code for Build-Bicep (Invoke-BicepBuild), ConvertTo-Bicep.

Add -Exclude parameter to Invoke-BicepBuild

Is your feature request related to a problem? Please describe.
When compiling all bicep files in a folder there might be a file that's work in progress, that will generate a lot of errors in the terminal output.

Describe the solution you'd like
Add -Exclude parameter to Invoke-BicepBuild.

Example:
Invoke-BicepBuild -Path c:\bicep\modules\ -Exclude appgw.bicep

This should compile all files in the folder except appgw.bicep

New cmdlet to fetch API reference docs - Get-BicepApiReference

Is your feature request related to a problem? Please describe.
When authoring templates you often find your self navigating to the API specification in the browser to look up properties. We should have a cmdlet that finds the docs for you and opens it in a browser.

Describe the solution you'd like
Implement a command called Get-BicepApiReference that opens the API reference in a browser.

Get the API reference for a resource defined in a template
Lets say you have a template vnet.bicep file that contains a resource named MyVNet.

resource MyVNet 'Microsoft.Network/virtualNetworks@2020-06-01' = {
  name: vnetName
  location: 'westeurope'
  properties: {
    addressSpace: {
      addressPrefixes: addressPrefixes
    }
  }
}

To get the API Reference for the resource MyVnet in the template (Microsoft.Network/virtualNetworks API Version 2020-06-01 ). The following command should work.

Get-BicepApiReference -TemplateFile "/vnet.bicep" -Resource "MyVNet"

Get API reference for a resource not defined in a template
You should also be able to manually specify a resource provider, resource and API Version using the following parameters.

Get-BicepApiReference -ResourceProvider "Microsoft.Network" -Resource "virtualNetworks"

Or using the -ApiVersion parameter to get a specific API Version.

Get-BicepApiReference -ResourceProvider "Microsoft.Network" -Resource "virtualNetworks" -ApiVersion "2020-04-01"

Additional context

Add -OutputPath to Build-Bicep

Is your feature request related to a problem? Please describe.
We should have an equivalent to --outfile that exists in Bicep CLI
--outfile <file> Saves the output as the specified file path.

Describe the solution you'd like

Build-Bicep -Path .\vnet.bicep -OutputPath .\virtualNetork.json

Additional context
Add any other context or screenshots about the feature request here.

Create Update-BicepTypes cmdlet

Is your feature request related to a problem? Please describe.
With the implementation of Get-BicepApiReference we need a way for users to update the BicepTypes.json file.

Describe the solution you'd like
Implement a cmdlet named something like Update-BicepTypes to download the latest type info.

Additional context
Add any other context or screenshots about the feature request here.

Create build pipeline that compiles and publishes the module to PowerShell Gallery

Describe the solution you'd like
Implement a build pipeline that compiles the module and publishes it to PowerShell gallery when a new release is created in the repository.

  1. New release tag is created in repo
  2. Build pipeline is triggered
  3. Downloads assemblies from Bicep Repo
  4. Update/verify version in manifest
  5. Run Publish-Module -WhatIf
  6. Send result from step 5 to maintainers for approval
  7. Publish to PS Gallery

Additional context
Add any other context or screenshots about the feature request here.

Added progress bar to `Install-BicepCLI`

Describe the solution you'd like
Added progress bar to Install-BicepCLI to show users that something is cooking.

Additional context
Add any other context or screenshots about the feature request here.

ConvertTo-Bicep outputs decompile warning message multiple times

Describe the bug
When using ConvertTo-Bicep to decompile multiple ARM Templates at the same time the decompilation warning message generated by bicep decompile is generated multiple times.

To Reproduce
Add multiple ARM templates to a folder and run ConvertTo-Bicep.

PS C:\> ConvertTo-Bicep -Path C:\ARMTemplates
WARNING: Decompilation is a best-effort process, as there is no guaranteed mapping from ARM JSON to Bicep.
You may need to fix warnings and errors in the generated bicep file(s), or decompilation may fail entirely if an accurate conversion is not possible.
If you would like to report any issues or inaccurate conversions, please see https://github.com/Azure/bicep/issues.
WARNING: Decompilation is a best-effort process, as there is no guaranteed mapping from ARM JSON to Bicep.
You may need to fix warnings and errors in the generated bicep file(s), or decompilation may fail entirely if an accurate conversion is not possible.
If you would like to report any issues or inaccurate conversions, please see https://github.com/Azure/bicep/issues.
C:\ARMTemplates\nsg.bicep(6,10) : Error BCP017: Expected a resource identifier at this location.
WARNING: Decompilation is a best-effort process, as there is no guaranteed mapping from ARM JSON to Bicep.
You may need to fix warnings and errors in the generated bicep file(s), or decompilation may fail entirely if an accurate conversion is not possible.
If you would like to report any issues or inaccurate conversions, please see https://github.com/Azure/bicep/issues.
WARNING: Decompilation is a best-effort process, as there is no guaranteed mapping from ARM JSON to Bicep.
You may need to fix warnings and errors in the generated bicep file(s), or decompilation may fail entirely if an accurate conversion is not possible.
If you would like to report any issues or inaccurate conversions, please see https://github.com/Azure/bicep/issues.

Expected behavior
The warning should only be printed once followed by the error logs from bicep decompile

Additional context
Add any other context about the problem here.

Create Uninstall-BicepCLI cmdlet

Describe the solution you'd like
Add a Uninstall-BicepCLI cmdlet that removes all installations of Bicep CLI.

Should remove both bicep.exe installed in the $env:USERPROFILE\.bicep and if installed using the Windows Installer the uninstaller located in "$env:LOCALAPPDATA\Programs\Bicep CLI" should be executed.

Additional context
Add any other context or screenshots about the feature request here.

Convertto-Bicep have issues with nested arm templates

Describe the bug
Convertto-Bicep sometimes writes error messages even though the decompile it self succeeds. This is because of how we loop through the result from $BicepObject = [Bicep.Decompiler.TemplateDecompiler]::DecompileFileWithModules($ResourceProvider, $FileResolver, $file.FullName).

image

Expected behavior
We need to make sure that all .bicep files named nested_... are being parsed before the main file.

Additional context
Add any other context about the problem here.

If cloned from repo, module can be loaded without DLLs installed.

Is your feature request related to a problem? Please describe.
Since moving Build-Bicep to use DLL instead of bicep.exe we need to have the compiled DLL files in the assets folder.

We have the DLLs in question set as required in the module manifest (psd1), but this is not a check that they actually exist.

This makes it so that you may actually import the module even if the DLL files are missing, which leads to all kinds of interesting errors.

This may not be a problem for installations from the gallery

We will, eventually, set up a proper build step to 'compile' the module for release, and in that step make sure that the required DLLs are part of the nuget package in the PowerShell Gallery,

but the problem will still be a part of running the module from the repo as we don't want compiled DLLs here.

Describe the solution you'd like
If the module is loaded without the DLLs in their assigned location either:

  • throw an error or warning when importing the module such as 'failed to load DLL files'
    or
  • throw a better error in all functions that requires the DLLs to function

Additional context
I am actually more leaning to solution number 2 as of now. We have the lifecycle CmdLets (Install, Uninstall, Update) that doesn't rely on DLL files. If a user uses the module for bicep.exe lifecycle management it should be easy to do so in any scenario.

New command to support converting JSON objects to Bicep Language

Is your feature request related to a problem? Please describe.
When authoring bicep templates you often find yourself in a situation where you have a property or a ARM template snippet that you want to convert to bicep format, instead of re-writing it as bicep.

Describe the solution you'd like
I would like to see a new command Convert-JsonToBicep could convert any valid JSON object to Bicep.

Example:
I have some JSON data.

$json = @"
[
  {
    "properties": {
      "NSGName": "subnet2-nsg",
      "SubnetName": "subnet2",
      "RouteName": "",
      "disableBgpRoutePropagation": true,
      "routes": []
    }
  },
  {
    "properties": {
      "NSGName": "subnet3-nsg",
      "SubnetName": "subnet3",
      "RouteName": "",
      "disableBgpRoutePropagation": false,
      "routes": []
    }
  }
]
"@

I then want to be able to run something like:
Convert-JsonToBicep -String $json

And it should return:

[
  {
    properties: {
      NSGName: 'subnet2-nsg'
      disableBgpRoutePropagation: true
      SubnetName: 'subnet2'
      routes: []
      RouteName: ''
    }
  }
  {
    properties: {
      NSGName: 'subnet3-nsg'
      disableBgpRoutePropagation: false
      SubnetName: 'subnet3'
      routes: []
      RouteName: ''
    }
  }
]

Additional context
Add any other context or screenshots about the feature request here.

Install-BicepCLI on a clean machine gives error.

Describe the bug

On a machine with no bicep CLI installed,
When running

Install-BicepCLI

It throws the following error

bicep:
Line |
   2 |      $bicep = (bicep --version)
     |                ~~~~~
     | The term 'bicep' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

To Reproduce
Steps to reproduce the behavior:

  1. Remove all bicep cli versions
  2. Run Install-BicepCLI

Expected behavior

No errors if the installer works

Implement Initialize-Bicep

Is your feature request related to a problem? Please describe.
Working with modules requires some work locating module files and the declaring the main.bicep file. As a complement to Restore-Bicep the cmdlet Initialize-Bicep should generate a base template using the modules restored.

Describe the solution you'd like
After Restore-Bicep has been executed to save module files from different repositories to a local folder, you should be able to run Initialize-Bicep to create a main.bicep file with all parameters from the module files and modules declared...

Will add more context and examples later(written from the phone)

Additional context
Add any other context or screenshots about the feature request here.

Convert-JsonToBicep sorting is off

Describe the bug
Convert-JsonToBicep rearrange the order of the properties in the objects. The issue is with ConvertFrom-Json -AsHashtable , need to write a custom function for this.

To Reproduce

 $json=@'
{
     "name": "Allow_Storage",
     "properties": {
         "provisioningState": "Succeeded",
         "protocol": "TCP",
         "sourcePortRange": "*",
         "destinationPortRange": "445",
         "sourceAddressPrefix": "VirtualNetwork",
         "destinationAddressPrefix": "Storage",
         "access": "Allow",
         "priority": 100,
         "direction": "Outbound"
     }
 }
 '@

Convert-JsonToBicep -String $json
{
  properties: {
    access: 'Allow'
    sourceAddressPrefix: 'VirtualNetwork'
    direction: 'Outbound'
    priority: 100
    destinationPortRange: '445'
    protocol: 'TCP'
    sourcePortRange: '*'
    destinationAddressPrefix: 'Storage'
    provisioningState: 'Succeeded'
  }
  name: 'Allow_Storage'
}


image

Expected behavior
The command should respect the order of the properties and output them in the same order.

Additional context
Add any other context about the problem here.

Update-BicepCLI and Install-BicepCLI should uninstall Bicep CLI installed to %userprofile%\.bicep

Describe the bug
If a user have installed Bicep CLI using the PowerShell script provided by the Bicep team or using our previous versions of the module, a bicep.exe will remain in the %userprofile%\.bicep. This will result in a conflict where the old version of Bicep CLI will be used over any version installed by the windows installer Update-BicepCLI and Install-BicepCLI.

To Reproduce
Install older version of Bicep CLI using PowerShell Script. Then install Bicep CLI using Install-BicepCLI.

Expected behavior
Install-BicepCLI and Update-BicepCLI should verify if there is a version installed to %userprofile%\.bicep, and if so delete it.

Additional context
Add any other context about the problem here.

Install-BicepCLI sometimes throws file locked error

Describe the bug
Sometimes when running Install-BicepCLI, it will throw an error when trying to start the installation because the installer is locked by another process.

To Reproduce
Steps to reproduce the behavior:

  1. Install-BicepCLI
  2. Sometimes you get an error. Not always

Expected behavior
The command should either wait for a bit before starting the installation or check for file locks before installing.

LatestBicepVersion uses Invoke-WebRequest, which breaks if IE is not run.

Describe the bug
LatestBicepVersion use webrequest it is dependent on IEs parsing engine.
Since the request is a pure json API we can simply replace it with Invoke-RestMethod instead

To Reproduce

  1. Dont have IE, or have a computer where it's never started.
  2. Run something the use LatestBicepVersion

bild

Expected behavior
It shouldn't error..

Start using PlatyPS for module help

Describe the solution you'd like
Implement PlatyPS for the module help files.

Additional context
Add any other context or screenshots about the feature request here.

Add HelpUri to functions

Describe the solution you'd like
Since we have all the documentation as markdown we should add HelpUri for each function which would point to the markdown file for that function. In that way its possible to use the -Online parameter for Get-Help.

Example:

function Build-Bicep {
    [CmdletBinding(DefaultParameterSetName = 'Default',
        SupportsShouldProcess,
        HelpUri = 'https://github.com/StefanIvemo/BicepPowerShell/blob/v1.4.2/Docs/Help/Build-Bicep.md')]
    ...
}

However, this should be release-specific, so we should not add a generic Url. It should be for the version installed (as in the example above).

Invoke-BicepBuild -GenerateParameterFiles cannot handle array and object parameters without default value properly

Describe the bug
Invoke-BicepBuild -GenerateParameterFiles cannot handle array and object parameters without default value properly.

To Reproduce
.bicep file:

param dnsservers array
param specailobject object

Running Invoke-BicepBuild -GenerateParameterFiles generates a ARM Template parameter file with value set to:

    "dnsservers ": {
      "value": "[]"
    },
    "specailobject ": {
      "value": "{}"
    }

Expected behavior
The JSON should look like this:

    "dnsservers ": {
      "value": []
    },
    "specailobject ": {
      "value": {}
    }

Additional context
Use ConvertTo-Json -InputObject instead of piping to ConvertTo-Json

Add -GenerateParameterFile to Invoke-BicepBuild

Is your feature request related to a problem? Please describe.
No

Describe the solution you'd like
Need a switch to Invoke-BicepBuild named something like -GenerateParameterFile. When the switch is used an ARM template parameter file should be generated.

Features:
-Add all parameters from the bicep file to the ARM template parameter file
-The default value for the parameter in the bicep file should be added to the ARM template parameter file

Example:
Invoke-BicepBuild -Path vnet.bicep -GenerateParamterFile

  1. Execute bicep build for the provided .bicep file(s)
  2. Fetch the compiled ARM template and generate a parameter file based on the template
  3. Name the parameter file to vnet.parameters.json

Suppress warning messages of specific code when running Build-Bicep

Is your feature request related to a problem? Please describe.
When running Build-Bicep I always get a lot of Warning BCP081: Resource type "..." does not have types available.

Once I've made sure they are reported as missing, I don't want to see these warnings any more since they make it hard to see any other warning that I might care about.

Describe the solution you'd like
I would like to have a configurable list of warnings that will be suppressed, either by Code or even better, by code and message.

I'm thinking a cmdlet like Add/Set/Get/Remove-BicepOption -SupressWarning 'BCP081'

The parameter SupressWarning would accept a string or a hashatble like this:

Add-BicepOption -SupressWarning @{
    Code='BCP81'
    Message = 'Resource type "Microsoft.Network/networkSecurityGroups@2020-08-01" does not have types available.'
}

These settings can be stored in a module-scoped variable and I can add them to my profile.ps1 to persist them between sessions, or maybe even be persisted to a file in my user profile?

GenerateParameterFile is missing a path parameter when Content is used

Describe the bug
If GenerateParameterFile is used with the Content parameter the parameter file will be created in the local directory.
There is no option to put it anywhere else.
When using Build-Bicep with the parameters -OutputDirectory and -GenerateParameterFile the json files will probably end up in different locations.

To Reproduce
Steps to reproduce the behavior:

  1. cd\
  2. Build-Bicep -Path D:\myconfig.bicep -OutputDirectory c:\mydir\ -GenerateParameterFile

The main json file will be created in c:\mydir.
The parameter file will be placed in the root.

Expected behavior
The user should be able to decide where to store the parameter file.

Implement error handling for ConvertTo-Bicep

Is your feature request related to a problem? Please describe.
After the implementation of bicep assemblies the command does not generate any decompile errors or warnings.

Describe the solution you'd like
Same solution as for Build-Bicep

Additional context
Add any other context or screenshots about the feature request here.

Create cmdlet to view bicep diagnostics

Is your feature request related to a problem? Please describe.
New functionality for Bicep CLI is being discussed to support validating targetScope for a template (see Azure/bicep#1562)

Describe the solution you'd like
We should keep track on this to make sure that we implement this feature as well, or maybe create our own version of Bicep diagnostics.

Get-BicepDiagnostics -Path vnet.bicep

Build warnings:  4
Build errors: 5 
targetScope: subscription
resourcesDeployed: 2
requiredParameters:  name <string>, addressSpaces <array>

Additional context
Add any other context or screenshots about the feature request here.

Update Install-BicepCLI to use the Windows Installer instead of PowerShell

Is your feature request related to a problem? Please describe.
Install-BicepCLI is installed using PowerShell by downloading bicep.exe from the latest release.

Describe the solution you'd like
The Windows Installer provided in the official Bicep repository is now signed and should be used instead. This will also simplify the Uninstall-BicepCLI command since it doesn't need to look in two different paths.

Additional context
Azure/bicep#1209

Bicep not recognized in WSL pwsh

Describe the bug
Fails to recognize that Bicep is installed and get installed version

To Reproduce
Steps to reproduce the behavior:

  1. Run Get-BicepVersion
  2. Output:
    InstalledVersion LatestVersion
    ---------------- -------------
    Not installed    0.3.126

Expected behavior

  1. Run Get-BicepVersion
  2. Output:
    InstalledVersion LatestVersion
    ---------------- -------------
    0.3.126             0.3.126

Additional context

Module version: 1.4.3 (installed with Install-Module)

$PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.1.3
PSEdition                      Core
GitCommitId                    7.1.3
OS                             Linux 5.4.72-microsoft-standard-WSL2 #1 SMP Wed Oct 28 23:40:43 UTC 2020
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
$bicep --version
Bicep CLI version 0.3.126 (a5e4c2e567)

Bicep installed with manual on Linux

Add the option to output Build-Bicep result as hashtable.

Is your feature request related to a problem? Please describe.
The Az PowerShell cmdlets New-Az*Deployment have a parameter named -TemplateObject that accepts the template in hashtable format. Today you can use Build-Bicep dns.bicep -AsString | ConvertFrom-Json -AsHashtable and pass it to the -TemplateObject to deploy resources.

Describe the solution you'd like
We should support something like Build-Bicep -Path dns.bicep -AsHashtable.

Additional context
Add any other context or screenshots about the feature request here.

Add support for parameter files to ConvertTo-Bicep

Is your feature request related to a problem? Please describe.
When running ConvertTo-Bicep it's only supported to provide an ARM template file. A bicep file will be generated with parameters using the default values from the ARM template.

Describe the solution you'd like
I want the possibility to provide a parameter file to ConvertTo-Bicep. When a parameter file is provided the ARM template should be updated with default values from the parameter file before bicep decompile is executed.

Example:
ConvertTo-Bicep -TemplateFile vnet.json -TemplateParameterFile vnet.parameters.json

  1. Get content from the two JSON files
  2. Update the default values in the ARM template with the values in the parameter file. The default property doesn't exist in the ARM template it should be added and value set to the value in the parameter file.
  3. Execute bicep decompile with the newly constructed JSON

Implement commands to create parameter files using Bicep syntax

Is your feature request related to a problem? Please describe.
We should implement commands to enable writing parameter files using Bicep syntax.

NOTE: This is not an official way of working with parameter files for Bicep. This is a workaround while waiting for native support for parameter files for Bicep.

Describe the solution you'd like
A bicep "parameter file" should be created by authoring a .bicep file containing variables only.

Example parameter file:

var vnetName = 'westeurope-hub-vnet'
var publicIPCount = 4
var customRoutes= [
  {
    name: 'To-Internet'
    properties: {
      addressPrefix: '0.0.0.0/0'
      nextHopType: 'None'
    }
  }
]

We should have two cmdlets supporting parameter files.

Build-BicepParameterFile
Should compile a .bicep file with variables only to a ARM Template Parameter file format in JSON.

Build-BicepParameterFile -ParameterFile "./vnet.parameters.bicep"

This should generate a ARM Template parameter file that looks like this:

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "vnetName": {
      "value": "westeurope-hub-vnet"
    },
    "publicIPCount ": {
      "value": 4
    },
    "customRoutes": {
      "value": [
        {
          "name": "To-Internet",
          "properties": {
            "addressPrefix": "0.0.0.0/0",
            "nextHopType": "None"
          }
        }
      ]
    }
  }
}

New-BicepParameterFile
We should also be able to generate a parameter file in .bicep format by referring to a .bicep file.

You have a bicep template that looks like this.
Example:
nsg.bicep

param name string = 'nsg1'
param securityRules array = []
param tags object = {}
param location string = resourceGroup().location

resource nsg  'Microsoft.Network/networkSecurityGroups@2020-06-01' = {
    name: name
    location: location
    properties: {
        securityRules: securityRules
    }    
}

You should then be able to create a .bicep format paramter file by running the following cmdlet.

New-BicepParameterFile -TemplateFile "./nsg.bicep"

This should generate a parameter file that looks like this.

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "name": {
      "value": "nsg1"
    },
    "securityRules ": {
      "value": []
    },
    "tags ": {
      "value": {}
    },
    "location":{
      "value": ""
    }
  }
}

Additional context
This will most likely be replaced with core Bicep functionality once Bicep natively supports parameter files.

Additional functionality to Build-Bicep -GenerateParameterFile

Is your feature request related to a problem? Please describe.
The -GenerateParameterFile switch generates a parameter file with all parameters in the .bicep file. You should be able to specify what type of parameters should be added to the parameter file.

Describe the solution you'd like
-GenerateParameterFile should be a parameter supporting the following scenarios.

-GenerateParameterFile All - Should generate a parameter file with all parameters from template (Parameters with expressions should have expression as value)

-GenerateParameterFile Required - Should generate a parameter file with required parameters only

-GenerateParameterFile Default - Should generate a parameter file with all parameters that does not have an expression as default value

Additional context
Add any other context or screenshots about the feature request here.

Move and update the module docs

Describe the solution you'd like
With all new upcoming features the docs should move from the repository readme to a docs folder for more detailed documentation.

Additional context
Add any other context or screenshots about the feature request here.

Rename Invoke-BicepBuild to Build-Bicep

Describe the solution you'd like
Rename Invoke-BicepBuild to Build-Bicep. Add Invoke-BicepBuild as an alias to Build-Bicep.

Additional context
Add any other context or screenshots about the feature request here.

Add -Version parameter to Install-BicepCLI

Is your feature request related to a problem? Please describe.
Install-BicepCLI can only install the latest Bicep CLI version.

Describe the solution you'd like
Add a version switch to allow the user to specify which version to install.

Additional context
Add any other context or screenshots about the feature request here.

Add -WhatIf switch to Build-Bicep

Describe the solution you'd like
You should be able to quickly test if a -bicep file will generate build errors without outputting an ARM Template. This can be done by implementing a -WhatIf switch for Build-Bicep.

Example
Build-Bicep -Path "./apim.bicep" -WhatIf
This should not execute a build of the .bicep file. It should instead output any build errors or verify that the build will execute successfully.

Additional context
Requires #24 to be implemented.

Add CompatiblePSEditions to module manifest

Is your feature request related to a problem? Please describe.
Module does not work on PowerShell 5.

Describe the solution you'd like
Add CompatiblePSEditions to the module manifest.

Additional context
Add any other context or screenshots about the feature request here.

Get-BicepApiReference should open the API reference with the qurey string ?tabs=bicep

Is your feature request related to a problem? Please describe.
The ARM template reference docs have been updated with Bicep samples. We should open them when running the command.

Describe the solution you'd like
I would like to append ?tabs=bicep to the url when running the command!

image

Additional context
Add any other context or screenshots about the feature request here.

Add -Nightly switch to Install-BicepCLI

Is your feature request related to a problem? Please describe.
Sometimes you want to run the Bicep CLI nightly build.

Describe the solution you'd like
I would like to see a Install-BicepCLI -Nightly switch to fetch and install Bicep CLI using nightly build.

Additional context
Add any other context or screenshots about the feature request here.

Get-BicepApiReference opens wrong url when no parameters are provided

Describe the bug
Get-BicepApiReference has a default parameter set without any mandatory parameters. When running the command without any parameters you will be redirected to this url: https://docs.microsoft.com/en-us/azure/templates///

To Reproduce
Steps to reproduce the behavior:

  1. Get-BicepApiReference
  2. Check the Url on the opened browser window

Expected behavior
Two alternatives.

  1. The command throws an error because a mandatory parameter is missing (Type)
  2. The command opens the reference start page without extra trailing slashes: https://docs.microsoft.com/en-us/azure/templates/

Error using Uninstall-BicepCLI when only Windows Installer version is installed.

Describe the bug
When running Uninstall-BicepCLI on a device that only have the Bicep CLI installed by the Windows Installer you get an error.

To Reproduce

  1. Remove all Bicep versions from the device (Uninstall-BicepCLI -Force)
  2. Install bicep CLI using the windows installer or Install-BicepCLI
  3. Run Uninstall-BicepCLI - Force again.

image

Expected behavior
Uninstall-BicepCLI should verify if the .bicep folder exists in the user profile.

Additional context
Add any other context about the problem here.

Implement cmdlets to support use of modules from central repositories

Describe the solution you'd like
Implement the commands currently in the works to support the PwrOps way of working with Bicep modules, templates and solutions.

Add-BicepDependencyRepository
Find-BicepDependency
Add-BicepDependency
Get-BicepDependency
New-BicepSolution
Deploy-BicepSolution

**Additional context**
More info will come once the method is tested more in detail.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.