How Scope a Resource to Another Resource Deployed Via a Module #13348
lpmulligan
started this conversation in
Authoring Help
Replies: 1 comment 2 replies
-
You are trying to scope your resource to a module, not a resource (your VM). Create a new module to apply the data collection rule with your VM name as a parameter. Then inside your new module, use an Pseudo code: main.bicep module appVm = { ...}
module vmDataCollectionRule = {
scope: resourceGroup(ResourceGroup.name)
params: {
vmName: appVm.outputs.vmName
}
} new module param vmName string
resource vm '...' existing = {
name: vmName
}
resource dcrAssociation ... = {
scope: vm
} |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm having a problem getting around the issue of trying to associate a data collection rule to a VM resource that is deployed from the AVM VM template.
My target scope is set to
targetScope = 'subscription'
for the bicep file.I deploy the VM just fine.
But when trying to associate a data collection rule scoped to the VM I keep meeting with resistance. BTW, the data collection rule resides in another resource group deployed outside of this deployment with the VM.
VS Code says:
So my question is how can I associate the data collection rule with my VM? The only information I've seen -> https://learn.microsoft.com/en-us/azure/templates/microsoft.insights/datacollectionruleassociations?pivots=deployment-language-bicep has the target scope for the association as the target VM which I don't see how to reference in my current situation. Are there alternatives?
Beta Was this translation helpful? Give feedback.
All reactions