@@ -1004,6 +1004,116 @@ function Test-NewDeploymentFromTemplateAndParameterFileContainingDatetimeOutput
1004
1004
Assert-AreEqual $datetimeFormatted $datetimeOutput
1005
1005
}
1006
1006
1007
+ finally
1008
+ {
1009
+ # Cleanup
1010
+ Clean - ResourceGroup $rgname
1011
+ }
1012
+ }
1013
+
1014
+ <#
1015
+ . SYNOPSIS
1016
+ Tests deployment via template and parameter file containing a tags with different casing.
1017
+ #>
1018
+ function Test-NewDeploymentFromTemplateFileContainingTagsOutput
1019
+ {
1020
+ # Setup
1021
+ $rgname = Get-ResourceGroupName
1022
+ $rname = Get-ResourceName
1023
+ $rglocation = " West US 2"
1024
+
1025
+ try
1026
+ {
1027
+ # Test
1028
+ New-AzResourceGroup - Name $rgname - Location $rglocation
1029
+
1030
+ $tagsToCompare = @ {
1031
+ " MY_FIRST_TAG" = " tagValue" ;
1032
+ " MYFIRSTTAG" = " tagvalue2" ;
1033
+ " mysecondTag" = " tagValue3" ;
1034
+ " mythirdtag" = " tagvalue4"
1035
+ }
1036
+
1037
+ $parameters = @ { " tags" = $tagsToCompare }
1038
+
1039
+ $deployment = New-AzResourceGroupDeployment - Name $rname - ResourceGroupName $rgname - TemplateFile simpleTemplateWithTagsOutput.json - TemplateParameterObject $parameters
1040
+
1041
+ # Assert
1042
+ Assert-AreEqual Succeeded $deployment.ProvisioningState
1043
+
1044
+ $subId = (Get-AzContext ).Subscription.SubscriptionId
1045
+ $deploymentId = " /subscriptions/$subId /resourcegroups/$rgname /providers/Microsoft.Resources/deployments/$rname "
1046
+ $getById = Get-AzResourceGroupDeployment - Id $deploymentId
1047
+ Assert-AreEqual $getById.DeploymentName $deployment.DeploymentName
1048
+
1049
+ $tagsOutput = $getById.Outputs.tags.Value
1050
+
1051
+ $tagsOutputJson = ConvertTo-Json - Compress $tagsOutput
1052
+
1053
+ # Performs a case sensitive comparison
1054
+ # Doing a foreach on the keys and comparing against the JSON string
1055
+ # this needed because the flag -AsHashTable doesn't seem to work
1056
+ # in ConvertTo-Json cmdlet
1057
+ foreach ($tag in $tagsToCompare.Keys )
1058
+ {
1059
+ Assert-True { $tagsOutputJson -clike " *${tag} *" }
1060
+ }
1061
+ }
1062
+
1063
+ finally
1064
+ {
1065
+ # Cleanup
1066
+ Clean - ResourceGroup $rgname
1067
+ }
1068
+ }
1069
+
1070
+ <#
1071
+ . SYNOPSIS
1072
+ Tests deployment via template and parameter file containing a tags with different casing.
1073
+ #>
1074
+ function Test-NewDeploymentFromTemplateAndParameterFileContainingTagsOutput
1075
+ {
1076
+ # Setup
1077
+ $rgname = Get-ResourceGroupName
1078
+ $rname = Get-ResourceName
1079
+ $rglocation = " West US 2"
1080
+
1081
+ try
1082
+ {
1083
+ # Test
1084
+ New-AzResourceGroup - Name $rgname - Location $rglocation
1085
+
1086
+ $tagsToCompare = @ {
1087
+ " MY_FIRST_TAG" = " tagValue" ;
1088
+ " MYFIRSTTAG" = " tagvalue2" ;
1089
+ " mysecondTag" = " tagValue3" ;
1090
+ " mythirdtag" = " tagvalue4"
1091
+ }
1092
+
1093
+ $deployment = New-AzResourceGroupDeployment - Name $rname - ResourceGroupName $rgname - TemplateFile simpleTemplateWithTagsOutput.json - TemplateParameterFile simpleTemplateWithTagsOutputParameters.json
1094
+
1095
+ # Assert
1096
+ Assert-AreEqual Succeeded $deployment.ProvisioningState
1097
+
1098
+ $subId = (Get-AzContext ).Subscription.SubscriptionId
1099
+ $deploymentId = " /subscriptions/$subId /resourcegroups/$rgname /providers/Microsoft.Resources/deployments/$rname "
1100
+ $getById = Get-AzResourceGroupDeployment - Id $deploymentId
1101
+ Assert-AreEqual $getById.DeploymentName $deployment.DeploymentName
1102
+
1103
+ $tagsOutput = $getById.Outputs.tags.Value
1104
+
1105
+ $tagsOutputJson = ConvertTo-Json - Compress $tagsOutput
1106
+
1107
+ # Performs a case sensitive comparison
1108
+ # Doing a foreach on the keys and comparing against the JSON string
1109
+ # this needed because the flag -AsHashTable doesn't seem to work
1110
+ # in ConvertTo-Json cmdlet
1111
+ foreach ($tag in $tagsToCompare.Keys )
1112
+ {
1113
+ Assert-True { $tagsOutputJson -clike " *${tag} *" }
1114
+ }
1115
+ }
1116
+
1007
1117
finally
1008
1118
{
1009
1119
# Cleanup
0 commit comments