-
Notifications
You must be signed in to change notification settings - Fork 757
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
Parameters - First Release #9567
Comments
Was lead here from the docs on experimental features, but was a little hard to find an example of how to use the feature. storage_account_template.bicepparamusing './storage_account_template.bicep'
param location = 'westus2'
param kind = 'StorageV2' storage_account_template.bicepvar storageAccountName = 'store${uniqueString(resourceGroup().id)}'
param location string
param kind string
resource sa 'Microsoft.Storage/storageAccounts@2019-04-01' = {
name: storageAccountName
location: location
sku: {
name: 'Standard_LRS'
}
kind: kind
properties: {}
} |
Just tried out this feature and while I obviously prefer the new syntax, I did run into a problem that I hope will be addressed. Thing is, I have a few use cases where I pass some parameters inline with the Azure CLI instead of hard-coded in the param file. I realize I could simply add a dummy default value as a workaround, but that would also change the behavior of my template, since the parameter won't be mandatory anymore. Is there or will there be an official way of supporting this? |
@mattiasholm - I think #10454 captures the same problem, do you agree? |
@alex-frankel However, after testing some more I also noticed that the Azure CLI is currently blocking using --parameters repeatedly whenever a Bicep param file is used: Can not use --parameters argument more than once when using a .bicepparam file |
@mattiasholm, it is actually by design that we don't support inline parameters with bicepparam to allow for a simpler experience, but considering that it seems like several users have inline parameters as part of their deployment experience, we'll discuss supporting it by the first release! Thanks for letting us know |
It's probably late to be asking this, however given the depreciation of inline parameters, would it be feasible to scope in the usage of the That would open up or unblock so many use cases for the bicepparam. Anyone could just transition code from inline/dynamic params to loadjsoncontent. |
I can see use cases for allowing both inline params and environment variables in addition to param files. This would also align well with Terraform, for those of us who are using both! 😊 |
default.bicepparam 🟩
Then also ... build or just deploy already works 🟩# works with 'loadJsonContent'
bicep build-params ".\default.bicepparam"
# no need to build (as above) since AZ 9.7.0 which includes az.resources 6.6.1, also works with `loadJsonContent`
New-AzResourceGroupDeployment -TemplateParameterFile ".\default.bicepparam" I am sure I was using the same version 4 days ago and it wasn't working, however I am thankful for this 🥳🙏 for me below will be useful to replace dynamic params passed to param Global = {
global: loadJsonContent('Global-Config.json')
regional: loadJsonContent('Global-AEU1.json')
} |
I did some extra review of my dynamic param usage and I cannot move ALL of my dynamic params into the bicepparam file. I am expressing interest to continue to allow usage of dynamic params along with the new bicepparam capabilities. |
Same. We are using common parameters like project and environmentName on out templates:
For some templates we need to query existing properties of the resources and pass them as template parameters to avoid loosing state on re-deployment. For some templates we need to query objects ids from AAD to pass them as template parameters. For our projects current first release is a cool tech demo but is not usable for production templates. At some point environment variable support will make things easier. |
I believe this is still scheduled in the first release.
|
@brwilkinson can you provide an example or a mockup of what you are looking to try to do?
|
I believe Ben's goal is to do the following:
If |
Thank you @stephaniezyen and confirming @alex-frankel example covers the scenario. This is the current behavior in AZ cli and AZ powershell. We are aware that this dynamic parameter pattern was not in scope for the first release of bicepparam, however a few people included myself do rely on this feature, so would welcome it back. We will gain environment var ref in params, however I am not sure if it's a replacement for all dynamic param use cases. |
I think personally think that support for az deployment * create -f main.bicep --parameters params.bicepparam otherParam=foo should be put on hold because same should be workarounded with bicep build-params params.bicepparam --outfile otherParams.json
az deployment * create -f main.bicep --parameters otherParams.json otherParam=foo Reasoning:
|
I believe the two ideas are directly related, just looking at it from a different perspective.
Given we don't actually have What if we had... otherParams.bicepparamusing 'main.bicep'
param prefix = loadEnvVar('prefix')
param global = json(loadEnvVar('global')) Then in your deployment, you can pass in those values and they override or get bound to ENV vars on the cli? # az cli
az deployment * create -f main.bicep --parameters otherParams.bicepparam prefix=ACU1 global='[{"abc":123}]'
# powershell
$splatParams=@{
prefix = 'ACU1'
global = '[{"abc":123}]'
}
New-AzResourceGroupDeployment -TemplateFile main.bicep -TemplateParameterFile otherParams.bicepparam @splatParams Would it be functionally equivalent to what we have now i.e. what we have both asked for in this thread? Not saying this specific syntax, just the general idea. |
Removing feature flag for `.bicepparam` files for the first release closes #9567 ###### Microsoft Reviewers: [Open in CodeFlow](https://portal.fabricbot.ms/api/codeflow?pullrequest=https://github.com/Azure/bicep/pull/10871)
Has anyone been doing any testing with bicepparam ? bicepparam fileusing '../../bicep/01-ALL-RG.bicep'
param Prefix = 'AWU3'
param Environment = 'P'
param DeploymentID = '0'
param Global = {} I am using PowerShell - Az.Resources Module - 6.7.0 Dynamic parameters and also overriding This is the format that I currently use, that works... I tested some other formats that do not appear to work, however I haven't tested extensively. example template - aaaas.bicepparam abc string
param global object
output abc string = abc
output global object = global example bicepparam file - aaaas.bicepparamusing 'aaaas.bicep'
param abc = '123'
param global = {} The way I do my powershell for dynamic parameters $ResourceGroupName = 'AWU3-PE-AD-RG-P0'
$DeploymentName = 'mytest'
$TemplateParametersFile = 'D:\repos\ADF\ADF\bicep\demos\aaaas.bicepparam'
$TemplateFile = 'D:\repos\ADF\ADF\bicep\demos\aaaas.bicep'
$TemplateArgs = @{ }
$TemplateArgs.Add('TemplateParameterFile', $TemplateParametersFile)
$TemplateArgs.Add('TemplateFile', $TemplateFile)
$Global = @{ }
$Global.Add('test', 678)
$OptionalParameters = @{ }
$OptionalParameters['Global'] = $Global
$Common = @{
Name = $DeploymentName
Location = $ResourceGroupLocation
Verbose = $true
ErrorAction = 'Continue'
ErrorVariable = 'e'
}
$Common.Remove('Location')
$Common['ResourceGroupName'] = $ResourceGroupName
New-AzResourceGroupDeployment @Common @TemplateArgs @OptionalParameters
DeploymentName : mytest
ResourceGroupName : AWU3-PE-AD-RG-P0
ProvisioningState : Succeeded
Timestamp : 6/19/2023 8:17:36 PM
Mode : Incremental
TemplateLink :
Parameters :
Name Type Value
=============== ========================= ==========
abc String "123"
global Object {"test":678}
Outputs :
Name Type Value
=============== ========================= ==========
abc String "123"
global Object {"test":678} EDIT: Now I can't break it, it always appears to work, simple repro that works below. New-AzResourceGroupDeployment -global @{test=123} -TemplateParameterFile .\aaaas.bicepparam -TemplateFile .\aaaas.bicep -ResourceGroupName $ResourceGroupName -verbose |
Main Story: #7301
First Release - Plans
Here are the features we're proposing for the first official release (combination of the "Summer" & "MVP" section - with some MVP pieces cut out). Most of the "Summer" work has already been completed, which is why it's not included here.
Basic Language Features
Code Completion and Navigation
Add support for parameter names refactoring #9568 Add support for parameter names refactoringI can use Find Ref to pull up a VS Code window that shows all references to a parameter (right click - find all references)Environment Variables
Bicep Parameter File Generation
Compatibility with Current Tooling
Other
If time permits
The text was updated successfully, but these errors were encountered: