Existing resources behavior #2300
-
hello, Based on the following feature (existing resources) : https://github.com/Azure/bicep/blob/main/docs/tutorial/05-loops-conditions-existing.md#existing-keyword I have a simple question: What is happening if the resource is not existing, because, in my case, the resource is created, which is very helpful, is it the standard behavior ? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
As long as you ensure the new resource is created before your use of the main.bicep resource storageAcc 'Microsoft.Storage/storageAccounts@2021-02-01' = {
name: 'mystorageacc'
kind: 'StorageV2'
location: 'West US'
sku: {
name: 'Standard_LRS'
}
}
module applyLock './lock.bicep' = {
name: 'applyLock'
params: {
// by referencing the storageAcc here, we ensure the module is deployed AFTER the storage account
accountName: storageAcc.name
}
} lock.bicep param accountName string
// This module is deployed AFTER the storage account, so we can safely obtain a reference to the account here
resource storageAcc 'Microsoft.Storage/storageAccounts@2021-02-01' existing = {
name: accountName
}
resource lockResource 'Microsoft.Authorization/locks@2016-09-01' = {
name: 'DontDelete'
scope: storageAcc
properties: {
level: 'CanNotDelete'
}
} Does that help, or am I misunderstanding the question? |
Beta Was this translation helpful? Give feedback.
-
I think this is what is happening: https://docs.microsoft.com/en-us/answers/questions/27211/what-is-the-networkwatcherrg.html |
Beta Was this translation helpful? Give feedback.
I think this is what is happening: https://docs.microsoft.com/en-us/answers/questions/27211/what-is-the-networkwatcherrg.html