Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

integrate bicep CLI into az CLI and az powershell #858

Closed
alex-frankel opened this issue Nov 9, 2020 · 11 comments
Closed

integrate bicep CLI into az CLI and az powershell #858

alex-frankel opened this issue Nov 9, 2020 · 11 comments
Assignees
Labels
enhancement New feature or request
Projects
Milestone

Comments

@alex-frankel
Copy link
Collaborator

alex-frankel commented Nov 9, 2020

The following commands should all work in Az CLI and Azure PowerShell respectively:

Compile and deploy a bicep file without emitting a main.json file

az deployment group create -f ./main.bicep -g my-rg
New-AzResourceGroupDeployment -TemplateFile ./main.bicep -ResourceGroupName my-rg

Run what-if and ask for confirmation before deploying:

az deployment group create -f ./main.bicep -g my-rg -c
New-AzResourceGroupDeployment -TemplateFile ./main.bicep -ResourceGroupName my-rg -Confirm

Transpile a .bicep file to its equivalent .json file

az bicep build ./main.bicep
Invoke-AzBicepBuild -File ./main.bicep

Both command line tools should check if the bicep exe is installed on the machine. If it's not, the user should be prompted to do so in an easy way. Similar to how kubectl is handled today for AKS command-line scenarios.

*** added 1/6 ***

Decompile an ARM Template into it's equivalent .bicep file

az bicep decompile ./main.json
Invoke-AzBicepDecompile -File ./main.json

Needs to support source-mapping of some kind. Since end user's wont' be interfacing with template JSON anymore, we need to make sure that errors returned during a deployment are mapped to the relevant spot in the bicep file. It should degrade gracefully.

  • If there is a line number in the JSON, that should map to a line number in bicep
  • If there is no line number, but there is a resource name and type, we should be able to point you there in the bicep file

Described in more detail in #855

@alex-frankel alex-frankel added the enhancement New feature or request label Nov 9, 2020
@ghost ghost added the Needs: Triage 🔍 label Nov 9, 2020
@alex-frankel alex-frankel added this to the v0.3 milestone Nov 9, 2020
@alex-frankel alex-frankel self-assigned this Nov 12, 2020
@alex-frankel alex-frankel added this to In Progress in 0.3 release Nov 16, 2020
@azcloudfarmer azcloudfarmer moved this from In Progress to In Review in 0.3 release Dec 1, 2020
@alex-frankel alex-frankel moved this from In Review to To Do in 0.3 release Dec 7, 2020
@alex-frankel
Copy link
Collaborator Author

Discussed with PowerShell and Az CLI team, and our plan will be to follow the AKS/kubectl model which does the following:

  • There is a dedicated cmdlet/command for installing kubectl (az aks install-cli)
  • Any commands that need kubectl will expect the binary to exist in a well-known location. If there, it will call the binary. If it is not there, the user will be prompted to run the above command.

As part of this issue, we should aim to start #800 in parallel.

@alex-frankel
Copy link
Collaborator Author

Discussed with @rynowak, who brought up that it would be helpful to be able to point to a custom install location of bicep so that you can use private or pre-release builds of bicep if you want to opt in. Not sure how AKS implements it, but if it is just pointing to well known PATHs, then it should be straightforward for user's to replace the binary manually and not build anything additional.

@miqm
Copy link
Collaborator

miqm commented Dec 29, 2020

@alex-frankel - will bicep be included in cli docker image?

@alex-frankel
Copy link
Collaborator Author

Good question. I think if we do nothing, it'll have the default version of Az CLI installed, so you will be prompted to install bicep when a relevant deployment command is invoked. I will add a note to see if we can have this installed on the image so that step doesn't need to happen.

@jbiesta
Copy link

jbiesta commented Jan 27, 2021

@alex-frankel Would this also include support for validating deployments (az deployment group validate) or just the creation of deployments?

@alex-frankel
Copy link
Collaborator Author

It should include any cli command/cmdlet that uses the --template-file/-TemplateFile, so the validation commands should be covered. Thanks for the reminder as we have a bad tendency to forget about this command!

@shenglol shenglol moved this from To Do to In Progress in 0.3 release Jan 28, 2021
This was referenced Feb 2, 2021
@azcloudfarmer azcloudfarmer moved this from In Progress to In Review in 0.3 release Feb 8, 2021
@StefanIvemo
Copy link
Collaborator

What is the progress with supporting deploying .bicep files using Az PowerShell and AZ CLI? What support can we expect as a first step? I looked at the code implemented so far and open PRs, and it seems that Azure CLI will support a lot more things thanks to @shenglol.

Also created an issue in the azure-powershell repo with some findings on the code implemented so far, Azure/azure-powershell#14289.

@alex-frankel
Copy link
Collaborator Author

alex-frankel commented Feb 23, 2021

The initial scope of support is to install the bicep CLI if it is not present and to automatically transpile the bicep code if it is provided as the value for the -TemplateFile parameter. PowerShell team is a bit more resource constrained so their implementation is going to be less feature rich than Az CLI at least to start. Let's see what powershell team has to say about the issue you filed - thank you for reporting the issues you've found.

Both Az CLI and Az PS support should be available in the next release that is set for the first week of March

@alex-frankel
Copy link
Collaborator Author

Both PS and CLI work for this has been merged and will be available on 3/2.

There is a slight difference in functionality. In Az CLI, we will install a self-contained version of bicep for CLI to use the first time you use a command that requires bicep. In Az PS, you need to manage the install of bicep yourself and ensure it is available on the PATH. We are planning to add an Install-AzBicep cmdlet, but this will not be in the first release.

@tfitzmac - I think it will be important to doc these discrepancies. Do you want me to update the installation instructions that are in this repo or will you plan to take care of this as part of the move to MS Docs?

@tfitzmac
Copy link

@alex-frankel - I think we should update in the Bicep repo. When the doc has been published, we can decide if we want to maintain both places.

@StefanIvemo
Copy link
Collaborator

Just tested the Azure CLI code using the installer from the PR build. It works great! Only found one minor issue, Azure/azure-cli#17083.

@alex-frankel I agree that it's very important to doc the difference between Azure CLI and Az PowerShell. And also write a note about the install path for the self-contained version installed by Azure CLI in %userprofile%\.Azure\bin\. Depending on how you've been installing Bicep CLI you might end up with bicep.exe in three different directories, and possibly different versions for Windows users (PowerShell script installer, Windows installer and Azure CLI installed).

@ghost ghost locked as resolved and limited conversation to collaborators May 29, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
No open projects
0.3 release
  
Done
Development

No branches or pull requests

6 participants