-
Notifications
You must be signed in to change notification settings - Fork 772
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
Behavior of exported variables in file published to ACR is different to a local file. #16256
Comments
The issue is the |
When I do a simple test with taking the id and outputting it using the local file it works fine. // main.bicep
import { acrPull } from 'roles.bicep'
// If you add an output and deploy this it shows the full resourceId
output id string = acrPull.id
// Shows: id = '/subscriptions/<my-sub-id-removed>/providers/Microsoft.Authorization/roleDefinitions/7f951dda-4ed3-4680-a7ca-43fe172d538d' I have been using the local |
I get the use case, but I think it's a bug that you can do this with a local file since Can you use a function instead? // roles.bicep
@export()
func acrPull() object => {
id: subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '7f951dda-4ed3-4680-a7ca-43fe172d538d')
name: 'AcrPull'
} |
Thanks for the detail as to why it was not working and the example code. Using the information you provided I added a new function to my Posting below as others may find it useful: // roles.bicep
@export()
func roleDefinitionId(roleId string) string => subscriptionResourceId('Microsoft.Authorization/roleDefinitions', roleId)
// Added more than a single role
@export()
var acrPull = {
id: '7f951dda-4ed3-4680-a7ca-43fe172d538d'
name: 'AcrPull'
}
@export()
var acrPush = {
id: '8311e382-0749-4cb8-b61a-304f252e45ec'
name: 'AcrPush'
} // main.bicep
import { roleDefinitionId, acrPull, acrPush } from 'br/vars:roles:<published-version>'
output acrPullRoleDefinitionId string = roleDefinitionId(acrPull.id)
// Outputs value as '/subscriptions/<my-sub-id-removed>/providers/Microsoft.Authorization/roleDefinitions/7f951dda-4ed3-4680-a7ca-43fe172d538d'
output acrPushRoleDefinitionId string = roleDefinitionId(acrPush.id)
// Outputs value as '/subscriptions/<my-sub-id-removed>/providers/Microsoft.Authorization/roleDefinitions/8311e382-0749-4cb8-b61a-304f252e45ec'
|
Bicep version
Bicep CLI version 0.33.93 (7a77c7f)
Bicep VSCode version 0.33.93
Describe the bug
The behavior of a working bicep file with exported variables functions differently depending on if it sourced as a local file or in an ACR
To Reproduce
Steps to reproduce the behavior:
This works:
This does not work:
Additional context
I would expect this to work as the contents of the file published to the ACR is the same as local 'roles.bicep' file which works.
The text was updated successfully, but these errors were encountered: