Skip to content

Commit b7660b4

Browse files
committed
Merge pull request Azure#1241 from independentwork/dev
Adds Intelligence Pack functions
2 parents 954ac93 + 15ba060 commit b7660b4

16 files changed

+4106
-2330
lines changed

src/ResourceManager/OperationalInsights/Commands.OperationalInsights.Test/Commands.OperationalInsights.Test.csproj

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@
5757
<Reference Include="Microsoft.Azure.Management.Authorization">
5858
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.1.0.0\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
5959
</Reference>
60-
<Reference Include="Microsoft.Azure.Management.OperationalInsights">
61-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.OperationalInsights.0.9.0-preview\lib\net40\Microsoft.Azure.Management.OperationalInsights.dll</HintPath>
62-
</Reference>
6360
<Reference Include="Microsoft.Azure.Gallery">
6461
<HintPath>..\..\..\packages\Microsoft.Azure.Gallery.2.6.2-preview\lib\net40\Microsoft.Azure.Gallery.dll</HintPath>
6562
</Reference>
63+
<Reference Include="Microsoft.Azure.Management.OperationalInsights">
64+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.OperationalInsights.0.10.0-preview\lib\net40\Microsoft.Azure.Management.OperationalInsights.dll</HintPath>
65+
</Reference>
6666
<Reference Include="Microsoft.Azure.ResourceManager, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
6767
<SpecificVersion>False</SpecificVersion>
6868
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Resources.2.18.7-preview\lib\net40\Microsoft.Azure.ResourceManager.dll</HintPath>
@@ -185,6 +185,9 @@
185185
<None Include="SessionRecords\Microsoft.Azure.Commands.OperationalInsights.Test.WorkspaceTests\TestWorkspaceCreateUpdateDelete.json">
186186
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
187187
</None>
188+
<None Include="SessionRecords\Microsoft.Azure.Commands.OperationalInsights.Test.WorkspaceTests\TestWorkspaceEnableDisableListIntelligencePacks.json">
189+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
190+
</None>
188191
</ItemGroup>
189192
<ItemGroup>
190193
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />

src/ResourceManager/OperationalInsights/Commands.OperationalInsights.Test/ScenarioTests/Common.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ function Get-ProviderLocation()
4848
{
4949
if ([Microsoft.Azure.Test.HttpRecorder.HttpMockServer]::Mode -ne [Microsoft.Azure.Test.HttpRecorder.HttpRecorderMode]::Playback)
5050
{
51-
$namespace = "OperationalInsights"
52-
$type = workspaces
51+
$namespace = "Microsoft.OperationalInsights"
52+
$type = "workspaces"
5353
$location = Get-AzureRmResourceProvider -ProviderNamespace $namespace | where {$_.ResourceTypes[0].ResourceTypeName -eq $type}
5454

5555
if ($location -eq $null)

src/ResourceManager/OperationalInsights/Commands.OperationalInsights.Test/ScenarioTests/WorkspaceTests.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@ public void TestWorkspaceCreateUpdateDelete()
3131
public void TestWorkspaceActions()
3232
{
3333
RunPowerShellTest("Test-WorkspaceActions");
34-
}
34+
}
35+
36+
[Fact]
37+
[Trait(Category.AcceptanceType, Category.CheckIn)]
38+
public void TestWorkspaceEnableDisableListIntelligencePacks()
39+
{
40+
RunPowerShellTest("Test-WorkspaceEnableDisableListIntelligencePacks");
41+
}
3542
}
3643
}

src/ResourceManager/OperationalInsights/Commands.OperationalInsights.Test/ScenarioTests/WorkspaceTests.ps1

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,4 +143,71 @@ function Test-WorkspaceActions
143143
Assert-NotNull $usages[0].NextResetTime
144144
Assert-AreEqual "Bytes" $usages[0].Unit
145145
Assert-AreEqual ([Timespan]::FromDays(1)) $usages[0].QuotaPeriod
146+
}
147+
148+
<#
149+
.SYNOPSIS
150+
Enable, disable, and list intelligence packs and verify the results
151+
#>
152+
function Test-WorkspaceEnableDisableListIntelligencePacks
153+
{
154+
155+
$wsname = Get-ResourceName
156+
$rgname = Get-ResourceGroupName
157+
$wslocation = Get-ProviderLocation
158+
159+
New-AzureRmResourceGroup -Name $rgname -Location $wslocation -Force
160+
161+
# Create and get a workspace
162+
$workspace = New-AzureRmOperationalInsightsWorkspace -ResourceGroupName $rgname -Name $wsname -Location $wslocation -Sku free -Tags @{"tag1" = "val1"} -Force
163+
Assert-AreEqual $rgname $workspace.ResourceGroupName
164+
Assert-AreEqual $wsname $workspace.Name
165+
Assert-AreEqual $wslocation $workspace.Location
166+
Assert-AreEqual "free" $workspace.Sku
167+
Assert-NotNull $workspace.ResourceId
168+
Assert-AreEqual 1 $workspace.Tags.Count
169+
Assert-NotNull $workspace.CustomerId
170+
Assert-NotNull $workspace.PortalUrl
171+
172+
# Enable intelligence packs
173+
Set-AzureRmOperationalInsightsIntelligencePack -ResourceGroupName $rgname -WorkspaceName $wsname -IntelligencePackName "ChangeTracking" -Enabled $true
174+
Set-AzureRmOperationalInsightsIntelligencePack -ResourceGroupName $rgname -WorkspaceName $wsname -IntelligencePackName "SiteRecovery" -Enabled $true
175+
176+
# List to verify that the IP's have been enabled
177+
$ipList = Get-AzureRmOperationalInsightsIntelligencePacks -ResourceGroupName $rgname -WorkspaceName $wsname
178+
Foreach ($ip in $ipList)
179+
{
180+
if (($ip.Name -eq "ChangeTracking") -or ($ip.Name -eq "SiteRecovery") -or ($ip.Name -eq "LogManagement"))
181+
{
182+
Assert-True $ip.Enabled
183+
}
184+
else
185+
{
186+
Assert-False $ip.Enabled
187+
}
188+
}
189+
190+
# Disable intelligence packs
191+
Set-AzureRmOperationalInsightsIntelligencePack -ResourceGroupName $rgname -WorkspaceName $wsname -IntelligencePackName "ChangeTracking" -Enabled $false
192+
Set-AzureRmOperationalInsightsIntelligencePack -ResourceGroupName $rgname -WorkspaceName $wsname -IntelligencePackName "SiteRecovery" -Enabled $false
193+
194+
# List to verify that the IP's have been disabled
195+
$ipList = Get-AzureRmOperationalInsightsIntelligencePacks -ResourceGroupName $rgname -WorkspaceName $wsname
196+
Foreach ($ip in $ipList)
197+
{
198+
if ($ip.Name -eq "LogManagement")
199+
{
200+
Assert-True $ip.Enabled
201+
}
202+
else
203+
{
204+
Assert-False $ip.Enabled
205+
}
206+
}
207+
208+
# Delete the original workspace via piping
209+
$workspace | Remove-AzureRmOperationalInsightsWorkspace -Force
210+
$workspaces = Get-AzureRmOperationalInsightsWorkspace -ResourceGroupName $rgname
211+
Assert-AreEqual 0 $workspaces.Count
212+
Assert-ThrowsContains { Get-AzureRmOperationalInsightsWorkspace -ResourceGroupName $rgname -Name wsname } "ResourceNotFound"
146213
}

0 commit comments

Comments
 (0)