@@ -198,6 +198,42 @@ function Test-NewAzAksAddons
198
198
}
199
199
}
200
200
201
+ function Test-EnableAndDisableAzAksAddons
202
+ {
203
+ # Setup
204
+ $resourceGroupName = Get-RandomResourceGroupName
205
+ $kubeClusterName = Get-RandomClusterName
206
+ $kubeClusterName2 = Get-RandomClusterName
207
+
208
+ try
209
+ {
210
+ New-AzResourceGroup - Name $resourceGroupName - Location ' eastus'
211
+
212
+ $cluster = New-AzAksCluster - ResourceGroupName $resourceGroupName - Name $kubeClusterName
213
+ Assert-Null $cluster.AddonProfiles
214
+
215
+ $cluster = $cluster | Enable-AzAksAddon - Name HttpApplicationRouting
216
+ Assert-AreEqual $true $cluster.AddonProfiles [' httpapplicationrouting' ].Enabled
217
+ $cluster = $cluster | Disable-AzAksAddon - Name HttpApplicationRouting
218
+ Assert-AreEqual $false $cluster.AddonProfiles [' httpapplicationrouting' ].Enabled
219
+
220
+ $cluster2 = New-AzAksCluster - ResourceGroupName $resourceGroupName - Name $kubeClusterName2
221
+ Assert-Null $cluster2.AddonProfiles
222
+ # $workspace = New-AzOperationalInsightsWorkspace -Location $location -Name 'akstestws' -ResourceGroupName $resourceGroupName
223
+ # $workspaceId = $workspace.ResourceId
224
+ $workspaceId = ' /subscriptions/0b1f6471-1bf0-4dda-aec3-cb9272f09590/resourceGroups/akstestgroup/providers/Microsoft.OperationalInsights/workspaces/akstestws'
225
+
226
+ $cluster2 = Enable-AzAksAddon - Name ' Monitoring' - WorkspaceResourceId $workspaceId - ResourceGroupName $resourceGroupName - ClusterName $kubeClusterName2
227
+ Assert-AreEqual $true $cluster2.AddonProfiles [' omsagent' ].Enabled
228
+ $cluster2 = Disable-AzAksAddon - Name ' Monitoring' - ResourceGroupName $resourceGroupName - ClusterName $kubeClusterName2
229
+ Assert-AreEqual $false $cluster2.AddonProfiles [' omsagent' ].Enabled
230
+ }
231
+ finally
232
+ {
233
+ Remove-AzResourceGroup - Name $resourceGroupName - Force
234
+ }
235
+ }
236
+
201
237
202
238
<#
203
239
. SYNOPSIS
0 commit comments