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

Validate scope when deploying a bicep file with Azure CLI / Azure Powershell #1562

Closed
shenglol opened this issue Feb 16, 2021 · 2 comments · Fixed by Azure/azure-cli#17547
Closed
Assignees
Labels
enhancement New feature or request
Projects
Milestone

Comments

@shenglol
Copy link
Contributor

We should check if targetScope matches the deployment scope when deploying a bicep file with the Azure CLI / Azure PowerShell deployment commands.

@shenglol shenglol added the enhancement New feature or request label Feb 16, 2021
@ghost ghost added the Needs: Triage 🔍 label Feb 16, 2021
@shenglol
Copy link
Contributor Author

shenglol commented Feb 16, 2021

One way to achieve this is to let the Bicep CLI take a new parameter (something like --deploymentScope) and let it output error if it doesn't match targetScope. However, the parameter will be useless if people invoke the bicep build command directly, and I feel like the Bicep CLI should be deployment agnostic. An alternative approach is to read targetScope of a bicep in Azure CLI / Azure PowerShell and then do the scope validation, but since we cannot access the AST in CLI and PowerShell, this may require us to implement a new Bicep CLI command which can output the value of targetScope upon invoking. I would like to hear people's thoughts on this.

@majastrz
Copy link
Member

Yeah given that this needs to work in Python and .net core, our options are limited. I see the following:

  1. Port just enough of the parser to parse the targetScope in Python. Pull in the real parser for PowerShell as a nuget.
  2. Hack "parse" it with regular expressions.
  3. Implement a special command to return this information like @shenglol suggests above.

1 and 2 will likely cause maintenance issues and deviations between Bicep in the real parser vs. the ported/hacked versions. So we definitely shouldn't do those options unless we don't have a choice.

Feels like option 3 is the best option. My suggestion on this one is to name it something more generic than bicep getTargetScope. Maybe something like bicep diagnostics or bicep info? We should have a contract for the output of the command and we should make sure we keep backwards-compatibility in mind when extending it. Perhaps simply a JSON file that we add new properties to?

@alex-frankel alex-frankel added this to the v0.4 milestone Feb 17, 2021
@alex-frankel alex-frankel changed the title Validate scope when deploying a bicpe file with Azure CLI / Azure Powershell Validate scope when deploying a bicep file with Azure CLI / Azure Powershell Mar 17, 2021
@shenglol shenglol self-assigned this Mar 25, 2021
@shenglol shenglol added this to In progress in 0.4 release Mar 25, 2021
@shenglol shenglol moved this from In progress to In Review in 0.4 release Apr 2, 2021
@stephaniezyen stephaniezyen moved this from In Review to Done in 0.4 release Apr 8, 2021
@shenglol shenglol closed this as completed Apr 8, 2021
@ghost ghost locked as resolved and limited conversation to collaborators May 28, 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
3 participants