Skip to content
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
<Compile Include="Common\INetworkInterfaceReference.cs" />
<Compile Include="Common\IResourceReference.cs" />
<Compile Include="Common\NetworkClient.cs" />
<Compile Include="Common\IOperationalInsightWorkspace.cs" />
<Compile Include="Version2017_03_01\ILoadBalancersOperations.cs" />
<Compile Include="Version2017_03_01\INetworkInterfacesOperations.cs" />
<Compile Include="Version2017_03_01\INetworkManagementClient.cs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------

using System;
using System.Collections.Generic;

namespace Microsoft.Azure.Management.Internal.Network.Common
{
public interface IOperationalInsightWorkspace
{
string ResourceId { get; set; }

string Location { get; set; }

Guid? CustomerId { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@
<ItemGroup>
<PackageReference Include="Microsoft.Azure.Management.ResourceManager" Version="1.6.0-preview" />
<PackageReference Include="Microsoft.Azure.Management.Compute" Version="17.5.0" />
<PackageReference Include="Microsoft.Azure.Management.Network" Version="17.0.0-preview" />
<PackageReference Include="Microsoft.Azure.Management.Network" Version="19.0.1-preview" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ public EnvironmentSetupHelper()
module = GetModuleManifest(StorageDirectory, "Azure.Storage");
LogIfNotNull($"Storage Data Plane Module path: {module}");
RMStorageDataPlaneModule = module;
module = GetModuleManifest(RmDirectory, "AzureRM.OperationalInsights");
LogIfNotNull($"Storage Data Plane Module path: {module}");
RMOperationalInsightsModule = module;
module = GetModuleManifest(RmDirectory, "AzureRM.Network");
LogIfNotNull($"Network Module path: {module}");
RMNetworkModule = module;
Expand Down Expand Up @@ -152,7 +155,9 @@ public EnvironmentSetupHelper()

public string RMInsightsModule { get; private set; }

public string RMStorageModule { get; private set; }
public string RMStorageModule { get; private set; }

public string RMOperationalInsightsModule { get; private set; }

//TODO: clarify (data plane should not be under ARM folder)
public string RMStorageDataPlaneModule { get; private set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@
<Reference Include="Microsoft.Azure.Management.Compute">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Compute.17.0.1\lib\net452\Microsoft.Azure.Management.Compute.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Management.Network, Version=15.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Network.15.1.0-preview\lib\net452\Microsoft.Azure.Management.Network.dll</HintPath>
<Reference Include="Microsoft.Azure.Management.Network, Version=19.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Network.19.0.1-preview\lib\net452\Microsoft.Azure.Management.Network.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Azure.Management.Storage, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<package id="Microsoft.Azure.Graph.RBAC" version="3.4.0-preview" targetFramework="net452" />
<package id="Microsoft.Azure.Management.Authorization" version="2.0.0" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Compute" version="17.0.1" targetFramework="net452" />
<package id="Microsoft.Azure.Management.Network" version="15.1.0-preview" targetFramework="net452" />
<package id="Microsoft.Azure.Management.Network" version="19.0.1-preview" targetFramework="net452" />
<package id="Microsoft.Azure.Management.Storage" version="4.1.0-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Test.Framework" version="1.0.6179.26854-prerelease" targetFramework="net45" />
<package id="Microsoft.Azure.Test.HttpRecorder" version="1.6.7-preview" targetFramework="net45" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@
<Reference Include="Microsoft.Azure.Management.Compute">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Compute.18.0.0\lib\net452\Microsoft.Azure.Management.Compute.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Management.Network, Version=19.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Network.19.0.0-preview\lib\net452\Microsoft.Azure.Management.Network.dll</HintPath>
<Reference Include="Microsoft.Azure.Management.Network, Version=19.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Network.19.0.1-preview\lib\net452\Microsoft.Azure.Management.Network.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Management.KeyVault, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<package id="Microsoft.Azure.Management.Authorization" version="2.0.0" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Compute" version="18.0.0" targetFramework="net452" />
<package id="Microsoft.Azure.Management.KeyVault" version="2.3.0-preview" targetFramework="net452" />
<package id="Microsoft.Azure.Management.Network" version="19.0.0-preview" targetFramework="net452" />
<package id="Microsoft.Azure.Management.Network" version="19.0.1-preview" targetFramework="net452" />
<package id="Microsoft.Azure.Management.Storage" version="4.1.0-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Test.Framework" version="1.0.6179.26854-prerelease" targetFramework="net45" />
<package id="Microsoft.Azure.Test.HttpRecorder" version="1.6.7-preview" targetFramework="net45" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Dns.2.2.0-preview\lib\net452\Microsoft.Azure.Management.Dns.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Azure.Management.Network, Version=19.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Network.19.0.0-preview\lib\net452\Microsoft.Azure.Management.Network.dll</HintPath>
<Reference Include="Microsoft.Azure.Management.Network, Version=19.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Network.19.0.1-preview\lib\net452\Microsoft.Azure.Management.Network.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Management.ResourceManager, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
Expand Down
2 changes: 1 addition & 1 deletion src/ResourceManager/Dns/Commands.Dns.Test/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<package id="Microsoft.Azure.Gallery" version="2.6.2-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Authorization" version="2.0.0" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Dns" version="2.2.0-preview" targetFramework="net452" />
<package id="Microsoft.Azure.Management.Network" version="19.0.0-preview" targetFramework="net452" />
<package id="Microsoft.Azure.Management.Network" version="19.0.1-preview" targetFramework="net452" />
<package id="Microsoft.Azure.Management.ResourceManager" version="1.1.1-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Resources" version="2.20.0-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Test.Framework" version="1.0.6179.26854-prerelease" targetFramework="net45" />
Expand Down
3 changes: 1 addition & 2 deletions src/ResourceManager/Network/AzureRM.Network.Netcore.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ PowerShellVersion = '5.1'
RequiredModules = @(@{ModuleName = 'AzureRM.Profile.Netcore'; ModuleVersion = '0.11.0'; })

# Assemblies that must be loaded prior to importing this module
RequiredAssemblies = '.\AutoMapper.dll',
'.\Microsoft.Azure.Management.Network.dll'
RequiredAssemblies = '.\AutoMapper.dll','.\Microsoft.Azure.Management.Network.dll'

# Script files (.ps1) that are run in the caller's environment prior to importing this module.
# ScriptsToProcess = @()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,11 @@
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.2.0.0\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Azure.Management.Network, Version=19.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Network.19.0.0-preview\lib\net452\Microsoft.Azure.Management.Network.dll</HintPath>
<Reference Include="Microsoft.Azure.Management.Network, Version=19.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Network.19.0.1-preview\lib\net452\Microsoft.Azure.Management.Network.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Management.OperationalInsights, Version=0.18.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.OperationalInsights.0.18.0-preview\lib\net45\Microsoft.Azure.Management.OperationalInsights.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Management.ResourceManager">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.ResourceManager.1.6.0-preview\lib\net452\Microsoft.Azure.Management.ResourceManager.dll</HintPath>
Expand Down Expand Up @@ -679,6 +682,10 @@
<Project>{98cfd96b-a6bc-4f15-ae2c-603fc2b58981}</Project>
<Name>Commands.Network</Name>
</ProjectReference>
<ProjectReference Include="..\..\OperationalInsights\Commands.OperationalInsights\Commands.OperationalInsights.csproj">
<Project>{5BE35A94-C20F-4659-AA29-9B9AEBCFAF36}</Project>
<Name>Commands.OperationalInsights</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
using Microsoft.Azure.Management.Redis;
using Microsoft.Azure.Management.Resources;
using Microsoft.Azure.Management.Storage;
using Microsoft.Azure.Management.OperationalInsights;
using Microsoft.Azure.Subscriptions;
using Microsoft.Azure.Test;
using Microsoft.Azure.Test.HttpRecorder;
Expand Down Expand Up @@ -52,6 +53,8 @@ public sealed class NetworkResourcesController

public StorageManagementClient StorageManagementClient { get; private set; }

public OperationalInsightsManagementClient OperationalInsightsManagementClient { get; private set; }

public InsightsManagementClient InsightsManagementClient { get; private set; }

public RedisManagementClient RedisManagementClient { get; private set; }
Expand Down Expand Up @@ -127,6 +130,7 @@ public void RunPsTestWorkflow(
helper.GetRMModulePath("AzureRM.RedisCache.psd1"),
helper.GetRMModulePath("AzureRM.Network.psd1"),
helper.GetRMModulePath("AzureRM.Compute.psd1"),
helper.GetRMModulePath("AzureRM.OperationalInsights.psd1"),
helper.RMStorageDataPlaneModule,
"AzureRM.Storage.ps1",
"AzureRM.Resources.ps1");
Expand Down Expand Up @@ -177,6 +181,7 @@ private void SetupManagementClients(RestTestFramework.MockContext context)
this.NetworkManagementClient = this.GetNetworkManagementClient(context);
this.ComputeManagementClient = this.GetComputeManagementClient(context);
this.StorageManagementClient = this.GetStorageManagementClient(context);
this.OperationalInsightsManagementClient = this.GetOperationalInsightsManagementClient(context);
this.AuthorizationManagementClient = this.GetAuthorizationManagementClient();
this.InsightsManagementClient = this.GetInsightsManagementClient();
this.RedisManagementClient = this.GetRedisManagementClient(context);
Expand All @@ -189,6 +194,7 @@ private void SetupManagementClients(RestTestFramework.MockContext context)
this.NetworkManagementClient,
this.ComputeManagementClient,
this.StorageManagementClient,
this.OperationalInsightsManagementClient,
this.AuthorizationManagementClient,
this.InsightsManagementClient,
this.RedisManagementClient);
Expand Down Expand Up @@ -219,6 +225,11 @@ private StorageManagementClient GetStorageManagementClient(RestTestFramework.Moc
return context.GetServiceClient<StorageManagementClient>(RestTestFramework.TestEnvironmentFactory.GetTestEnvironment());
}

private OperationalInsightsManagementClient GetOperationalInsightsManagementClient(RestTestFramework.MockContext context)
{
return context.GetServiceClient<OperationalInsightsManagementClient>(RestTestFramework.TestEnvironmentFactory.GetTestEnvironment());
}

private GalleryClient GetGalleryClient()
{
return TestBase.GetServiceClient<GalleryClient>(this.csmTestFactory);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -503,24 +503,23 @@ function Test-FlowLog
# Setup
$resourceGroupName = Get-ResourceGroupName
$nwName = Get-ResourceName
$location = "eastus"
#Since Traffic Analytics is not available in all Azure regions, hardcoded locations are used
#Once Traffic Analytics is available in all azure regions, the below two location variables should be updated to Get-Location
$location = "eastus2euap"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did not update as the same location field is used to create many resources and no all of them are available in new france regions. Let me know your thoughts here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should use a different location variable for each resource type and use Get-Location. This guarentees that you will be able to rerecord even when permissions to different regions change, or when you are in a different cloud (China, Fairfax).

Copy link
Contributor Author

@sayghosh sayghosh May 22, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually the NSG, NetworkWatcher and Storage Account has to be in same azure region while the workspace can be in any indepedent region, that is why there are 2 location variables used here. And to enable Traffic analytics, both the networkwatcher and WS has to be in a Traffic Analytics supported region. But currently Traffic Analytics is availble only on 14 azure regions. FOr now I can add a comment to it with reason why I could not use Get-Location there. Does this make sense? PLease adivse.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, adding the comment should be fine.

$workspaceLocation = "eastus"
$resourceTypeParent = "Microsoft.Network/networkWatchers"
$nwLocation = Get-ProviderLocation $resourceTypeParent
$nwRgName = Get-ResourceGroupName
$domainNameLabel = Get-ResourceName
$vnetName = Get-ResourceName
$subnetName = Get-ResourceName
$nsgName = Get-ResourceName
$stoname = Get-ResourceName
$workspaceName = Get-ResourceName

try
{
# Create Resource group
New-AzureRmResourceGroup -Name $resourceGroupName -Location "$location"

# Create the Virtual Network
$subnet = New-AzureRmVirtualNetworkSubnetConfig -Name $subnetName -AddressPrefix 10.0.1.0/24
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this just never used?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this was never used

$vnet = New-AzureRmvirtualNetwork -Name $vnetName -ResourceGroupName $resourceGroupName -Location $location -AddressPrefix 10.0.0.0/16 -Subnet $subnet

# Create NetworkSecurityGroup
$nsg = New-AzureRmNetworkSecurityGroup -name $nsgName -ResourceGroupName $resourceGroupName -Location $location

Expand All @@ -534,14 +533,20 @@ function Test-FlowLog
$nw = New-AzureRmNetworkWatcher -Name $nwName -ResourceGroupName $nwRgName -Location $location

# Create storage
$stoname = 'sto' + $resourceGroupName
$stoname = 'sto' + $stoname
$stotype = 'Standard_GRS'
$containerName = 'cont' + $resourceGroupName

New-AzureRmStorageAccount -ResourceGroupName $resourceGroupName -Name $stoname -Location $location -Type $stotype;
$sto = Get-AzureRmStorageAccount -ResourceGroupName $resourceGroupName -Name $stoname;

$job = Set-AzureRmNetworkWatcherConfigFlowLog -NetworkWatcher $nw -TargetResourceId $getNsg.Id -EnableFlowLog $true -StorageAccountId $sto.Id -AsJob
# create workspace
$workspaceName = 'tawspace' + $workspaceName
$workspaceSku = 'free'

New-AzureRmOperationalInsightsWorkspace -ResourceGroupName $resourceGroupName -Name $workspaceName -Location $workspaceLocation -Sku $workspaceSku;
$workspace = Get-AzureRmOperationalInsightsWorkspace -Name $workspaceName -ResourceGroupName $resourceGroupName

$job = Set-AzureRmNetworkWatcherConfigFlowLog -NetworkWatcher $nw -TargetResourceId $getNsg.Id -EnableFlowLog $true -StorageAccountId $sto.Id -EnableTrafficAnalytics:$true -Workspace $workspace -AsJob
$job | Wait-Job
$config = $job | Receive-Job
$job = Get-AzureRmNetworkWatcherFlowLogStatus -NetworkWatcher $nw -TargetResourceId $getNsg.Id -AsJob
Expand All @@ -554,11 +559,19 @@ function Test-FlowLog
Assert-AreEqual $config.Enabled $true
Assert-AreEqual $config.RetentionPolicy.Days 0
Assert-AreEqual $config.RetentionPolicy.Enabled $false
Assert-AreEqual $config.FlowAnalyticsConfiguration.NetworkWatcherFlowAnalyticsConfiguration.Enabled $true
Assert-AreEqual $config.FlowAnalyticsConfiguration.NetworkWatcherFlowAnalyticsConfiguration.WorkspaceResourceId $workspace.ResourceId
Assert-AreEqual $config.FlowAnalyticsConfiguration.NetworkWatcherFlowAnalyticsConfiguration.WorkspaceId $workspace.CustomerId.ToString()
Assert-AreEqual $config.FlowAnalyticsConfiguration.NetworkWatcherFlowAnalyticsConfiguration.WorkspaceRegion $workspace.Location
Assert-AreEqual $status.TargetResourceId $getNsg.Id
Assert-AreEqual $status.StorageId $sto.Id
Assert-AreEqual $status.Enabled $true
Assert-AreEqual $status.RetentionPolicy.Days 0
Assert-AreEqual $status.RetentionPolicy.Enabled $false
Assert-AreEqual $status.FlowAnalyticsConfiguration.NetworkWatcherFlowAnalyticsConfiguration.Enabled $true
Assert-AreEqual $status.FlowAnalyticsConfiguration.NetworkWatcherFlowAnalyticsConfiguration.WorkspaceResourceId $workspace.ResourceId
Assert-AreEqual $status.FlowAnalyticsConfiguration.NetworkWatcherFlowAnalyticsConfiguration.WorkspaceId $workspace.CustomerId.ToString()
Assert-AreEqual $status.FlowAnalyticsConfiguration.NetworkWatcherFlowAnalyticsConfiguration.WorkspaceRegion $workspace.Location
}
finally
{
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
<package id="Microsoft.Azure.Insights" version="0.13.1-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Authorization" version="2.0.0" targetFramework="net452" />
<package id="Microsoft.Azure.Management.Compute" version="18.0.0" targetFramework="net452" />
<package id="Microsoft.Azure.Management.Network" version="19.0.0-preview" targetFramework="net452" />
<package id="Microsoft.Azure.Management.Network" version="19.0.1-preview" targetFramework="net452" />
<package id="Microsoft.Azure.Management.OperationalInsights" version="0.18.0-preview" targetFramework="net452" />
<package id="Microsoft.Azure.Management.Redis" version="3.1.1-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Management.ResourceManager" version="1.6.0-preview" targetFramework="net452" />
<package id="Microsoft.Azure.Management.Resources" version="2.20.0-preview" targetFramework="net45" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

<ItemGroup>
<PackageReference Include="AutoMapper" Version="6.2.2" />
<PackageReference Include="Microsoft.Azure.Management.Network" Version="19.0.0-preview" />
<PackageReference Include="Microsoft.Azure.Management.Network" Version="19.0.1-preview" />
</ItemGroup>

<ItemGroup>
Expand Down
Loading