Skip to content

Instantly share code, notes, and snippets.

@jikuja
Last active October 4, 2021 11:24
Show Gist options
  • Save jikuja/cc050b3e8613b74a109a258868d62c90 to your computer and use it in GitHub Desktop.
Save jikuja/cc050b3e8613b74a109a258868d62c90 to your computer and use it in GitHub Desktop.
Bicep - resource related information

Resource functions

reference

  • reference(resourceName or resourceIdentifier, [apiVersion], ['Full'])
  • Returns an object representing a resource's runtime state.

resourceId

  • resourceId([subscriptionId], [resourceGroupName], resourceType, resourceName1, [resourceName2], ...)
  • Returns the unique identifier of a resource.

subscriptionResourceId

  • subscriptionResourceId([subscriptionId], resourceType, resourceName1, [resourceName2], ...)
  • Returns the unique identifier for a resource deployed at the subscription level.

Scope functions

tenant() // returns the tenant scope

managementGroup() // returns the current management group scope (only from managementGroup deployments)
managementGroup(name: string) // returns the scope for a named management group

subscription() // returns the subscription scope for the current deployment (only from subscription & resourceGroup deployments)
subscription(subscriptionId: string) // returns a named subscription scope (only from subscription & resourceGroup deployments)

resourceGroup() // returns the current resource group scope (only from resourceGroup deployments)
resourceGroup(resourceGroupName: string) // returns a named resource group scope (only from subscription & resourceGroup deployments)
resourceGroup(subscriptionId: string, resourceGroupName: string) // returns a named resource group scope (only from subscription & resourceGroup deployments)

Resource "scope" property

  • Accepts results of scope functions or symbolic reference to a scope
    • Resource reference created with resource keyword
    • Existing resource reference created with resource + exising keywords
    • resource id not accepted? TBD

Extension resource

  • Extension method scope must have same root resource scope than the bicep file
    • e.g. Bicep file with resource group scoping will fail directly to create a new role assignment into some other resource group
  • Is it possible to do deployment of extension resource when bicep scope is subscription?

Module

  • Scope can be selected freely
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment