AZ-400 · Question #511
Hotspot Question You have a management group that contains four Azure subscriptions. Each subscription contains four resource groups. You develop a new web app named App1. You plan to deploy an instan
The correct answer is param planname string = toLower('AppServicePlan-${uniqueString: (subscription().id)'; param appname string = toLower('app-${uniqueString: (resourceGroup().id)'. This hotspot question tests knowledge of Bicep template scoping, specifically how to use targetScope and subscription/resource group context functions to generate consistent names across subscriptions and resource groups.
Question
Exhibit
Answer Area
- param planname string = toLower('AppServicePlan-${uniqueString(subscription().id)'(deployment().name)'(resourceGroup().id)'('resourceGroupName')'(subscription().id)'
- param appname string = toLower('app-${uniqueString(resourceGroup().id)'(deployment().name)'(resourceGroup().id)'('resourceGroupName')'(subscription().id)'
Explanation
This hotspot question tests knowledge of Bicep template scoping, specifically how to use targetScope and subscription/resource group context functions to generate consistent names across subscriptions and resource groups.
Approach. The template should use 'targetScope = resourceGroup' at the top (or leave it as default since resourceGroup is the default scope). To generate consistent names for App1 instances, you use 'resourceGroup().name' and 'subscription().subscriptionId' in the naming convention so each instance gets a unique but deterministic name tied to its resource group and subscription context. For the App Service plan name, a similar pattern using resourceGroup().name ensures consistency. The key functions are resourceGroup().name to get the current resource group name and subscription().subscriptionId to get the subscription ID, which together guarantee uniqueness and consistency when the same template is deployed across all 16 resource group targets (4 subscriptions × 4 resource groups).
Concept tested. Bicep template scoping and use of built-in functions like resourceGroup().name and subscription().subscriptionId to generate consistent, deterministic resource names when deploying the same template across multiple subscriptions and resource groups in a management group hierarchy.
Reference. https://learn.microsoft.com/en-us/azure/azure-resource-manager/bicep/bicep-functions-resource#resourcegroup and https://learn.microsoft.com/en-us/azure/azure-resource-manager/bicep/deploy-to-management-group
Topics
Community Discussion
No community discussion yet for this question.
