Exam-Answer

Home / Microsoft / AZ-100 / Question 11

Prev Question
Next Question

Question 11

You use taxonomic tags to logically organize resources and to make billing reporting easier.

You use Azure PowerShell to append an additional tag on a storage account named corpstorage99. The code is as follows:

$r = Get-AzureRmResource -ResourceName "corpstorage99" -ResourceGroupName "prod-rg"

Set-AzureRmResource -Tag @{Dept="IT"} -ResourceId $r.ResourceId -Force

The code returns unexpected results.

You need to append the additional tag as quickly as possible.

What should you do?

Answers



A B C D

Advertisement

Explanation

You should call the Add() method on the storage account resource as shown in the second line of this refactored Azure PowerShell code:

$r = Get-AzureRmResource -ResourceName "corpstorage99" -ResourceGroupName "prod-rg"

$r.Tags.Add("Dept", "IT")

Set-AzureRmResource -Tag $r.Tags -ResourceId $r.ResourceId -Force

Unless you call the Add() method, the Set-AzureRmResource cmdlet will overwrite any existing taxonomic tags on the resource. The Add() method preserves existing tags and includes one or more tags to the resource tag list.

You should not deploy the tag by using an Azure Resource Manager template. Doing so is unnecessary in this case because the Azure PowerShell is mostly complete as-is. Furthermore, you must find the solution as quickly as possible.

You should not assign the Enforce tag and its value Azure Policy to the resource group. Azure Policy is a governance feature that helps businesses enforce compliance in resource creation. In this case, the solution involves too much administrative overhead to be a viable option. Moreover, the scenario makes no mention of the need for governance policy in specific terms.

You should not refactor the code by using the Azure Command-Line Interface (CLI). Either Azure PowerShell or Azure CLI can be used to institute this solution. It makes no sense to change the development language given that you have already completed most of the code in PowerShell.

References

Comments

Load more
Prev Question
Next Question