-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Powershell changes to onboard additional traffic analytics parameters with existing networkwatcher flowlog parameters #6253
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 13 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
046dbee
Powershell changes satge 1
sayghosh 433c297
Some small changes in required assembly list
sayghosh 8ec0fa8
Basic commandlets working
sayghosh fb4655c
Basic implementations done
sayghosh 3d1a7ef
Implementatioan and test file changes
sayghosh 868b861
Workspace object usage coded
sayghosh 865082d
Changes done
sayghosh 3cc698a
Optional and mandatory variables sorted
sayghosh e3b9110
Version updates
sayghosh 2f1b9ed
Resolving conflicts
sayghosh ca77eed
Updating test
sayghosh d53a9df
Reverting changes in service fabric test and squashing all commits in…
sayghosh b9a8657
Reverting service fabric changes
sayghosh 4aa6eb0
Resolving conflicts
sayghosh 5c1eee0
Adding help generation text
sayghosh fef626c
Cleaning the signatureIssues.csv file
sayghosh 19dd13d
Pushing minor string update to retrigger build
sayghosh 3e52bb2
Revising the service fabric changes
sayghosh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
src/Common/Commands.Common.Network/Common/IOperationalInsightWorkspace.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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" | ||
| $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 | ||
|
||
| $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 | ||
|
|
||
|
|
@@ -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 | ||
|
|
@@ -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 | ||
| { | ||
|
|
||
1,318 changes: 685 additions & 633 deletions
1,318
...essionRecords/Commands.Network.Test.ScenarioTests.NetworkWatcherAPITests/TestFlowLog.json
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use Get-Location for both of these: https://github.com/Azure/azure-powershell/wiki/Azure-Powershell-Developer-Guide#using-common-code
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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).
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.