Obučavanje
Modul
Deploy child and extension resources by using Bicep - Training
Learn how to deploy child and extension resources, and refer to existing resources, within your Bicep code.
Ovaj preglednik više nije podržan.
Nadogradite na Microsoft Edge da iskoristite najnovije osobine, sigurnosna ažuriranja i tehničku podršku.
To reference an existing resource that isn't deployed in your current Bicep file, declare the resource with the existing
keyword. Use the existing
keyword when you're deploying a resource that needs to get a value from an existing resource. You access the existing resource's properties through its symbolic name.
The resource isn't redeployed when referenced with the existing
keyword.
The following example gets an existing storage account in the same resource group as the current deployment. Notice that you provide only the name of the existing resource. The properties are available through the symbolic name.
resource stg 'Microsoft.Storage/storageAccounts@2023-04-01' existing = {
name: 'examplestorage'
}
output blobEndpoint string = stg.properties.primaryEndpoints.blob
Set the scope
property to access a resource in a different scope. The following example references an existing storage account in a different resource group.
resource stg 'Microsoft.Storage/storageAccounts@2023-04-01' existing = {
name: 'examplestorage'
scope: resourceGroup(exampleRG)
}
output blobEndpoint string = stg.properties.primaryEndpoints.blob
For more information about setting the scope, see Scope functions for Bicep.
If you attempt to reference a resource that doesn't exist, you get the NotFound
error and your deployment fails. Check the name and scope of the resource you're trying to reference.
For the syntax to deploy a resource, see Resource declaration in Bicep.
Obučavanje
Modul
Deploy child and extension resources by using Bicep - Training
Learn how to deploy child and extension resources, and refer to existing resources, within your Bicep code.
Dokumentacija
Outputs in Bicep - Azure Resource Manager
Describes how to define output values in Bicep
Bicep functions - scopes - Azure Resource Manager
Describes the functions to use in a Bicep file to retrieve values about deployment scopes.
Use Bicep to deploy resources to resource groups - Azure Resource Manager
Describes how to deploy resources in a Bicep file. It shows how to target more than one resource group.