I am new to bicep so I am might be missing something simple here. I have a container registry resource in subscription ‘sub1’ and resource group ‘rg1’. I created a bicep module which looks like below:
<code>@description('Name of the registry.')
param regName string
targetScope = 'subscription'
resource myreg 'Microsoft.ContainerRegistry/registries@2023-01-01' existing = {
name: regName
scope: resourceGroup('reg1')
}
output acrResource resource = myreg (NOTE: this is asking me to enable experimental features...which I want to avoid)
output acrId string = myreg.id
output acrName string = myreg.name
</code>
<code>@description('Name of the registry.')
param regName string
targetScope = 'subscription'
resource myreg 'Microsoft.ContainerRegistry/registries@2023-01-01' existing = {
name: regName
scope: resourceGroup('reg1')
}
output acrResource resource = myreg (NOTE: this is asking me to enable experimental features...which I want to avoid)
output acrId string = myreg.id
output acrName string = myreg.name
</code>
@description('Name of the registry.')
param regName string
targetScope = 'subscription'
resource myreg 'Microsoft.ContainerRegistry/registries@2023-01-01' existing = {
name: regName
scope: resourceGroup('reg1')
}
output acrResource resource = myreg (NOTE: this is asking me to enable experimental features...which I want to avoid)
output acrId string = myreg.id
output acrName string = myreg.name
I am using this bicep template like below:
<code>module myreg 'myreg.bicep'= {
name: 'myreg'
params: {
regName: 'foo'
}
scope: subscription('sub1')
}
resource roleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' {
name: 'guid-here'
properties: {
roleDefinitionId: acrPullRoleDefinitionId
principalId: 'principa-id-here'
}
scope: myreg.outputs.acrResource (this one does not work as I need to enable experimental feature to make the module file error go away)
}
</code>
<code>module myreg 'myreg.bicep'= {
name: 'myreg'
params: {
regName: 'foo'
}
scope: subscription('sub1')
}
resource roleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' {
name: 'guid-here'
properties: {
roleDefinitionId: acrPullRoleDefinitionId
principalId: 'principa-id-here'
}
scope: myreg.outputs.acrResource (this one does not work as I need to enable experimental feature to make the module file error go away)
}
</code>
module myreg 'myreg.bicep'= {
name: 'myreg'
params: {
regName: 'foo'
}
scope: subscription('sub1')
}
resource roleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' {
name: 'guid-here'
properties: {
roleDefinitionId: acrPullRoleDefinitionId
principalId: 'principa-id-here'
}
scope: myreg.outputs.acrResource (this one does not work as I need to enable experimental feature to make the module file error go away)
}
Questions:
How is an existing resource from different sub and resource group referenced in general? I could not find examples online too. This should be straight forward but I am stuck here. Any ideas on how I can get unblocked?
Thanks for your help.