Skip to content

Commit

Permalink
Monitor private link (#11407)
Browse files Browse the repository at this point in the history
* typo, unused imports. - enable severity, status tests. update properties count( since prod outage was removed). add tests for ticket status.

* properties count to 5

* count for prob class to 5

* fix get-azresource -ResourceGroupName -Name -ResourceType to use correct ApiVersion

* Complete cmdlet implementations

* fix get-azresource -ResourceGroupName -Name -ExpandProperties -ResourceType to use correct ApiVersion

* Fix Microsoft.Azure.PowerShell.Cmdlets.ManagedServices.dll.json

#10826

* Fix changelog merge issue

* remove override DefaultContext

* Restore-AzSqlInstanceDatabase - fix "an" -> "a"

Examples: fix "an deleted instance" to "a deleted instance"

* Add changelog entry

* chore) update privacy notice text

* Update changelog.md per contributing.md

* chore) minor text correction

* Improve PolicyInsights error messages

* Address reviwer comments

* Add note about the version of PowerShell

* fix changelog merge error

* Minor helper file fix

* update macos to 10.14

* Add DisableAzureSqlServerActiveDirectoryOnlyAuthentication.cs file itself.

* Add DisableAzureSqlServerActiveDirectoryOnlyAuthentication.cs file itself.

* disable one test case that is unstable on linux

* remove file

* add DisableAzureSqlServerActiveDirectoryOnlyAuthentication.cs

* Create DisableAzureSqlServerActiveDirectoryOnlyAuthentication.cs

* Update ChangeLog.md

add cmdlet Disable-AzSqlServerActiveDirectoryOnlyAuthentication

* Update ChangeLog.md

* SAP AEM: add support for the new VM Extension for SAP

* Update ChangeLog.md

remove edit to this file

* Update ChangeLog.md

* Add cmdlet Disable-AzSqlServerActiveDirectoryOnlyAuthentication to upcoming section.

* Fixing the parameter name IsAzureADOnlyAuthentication and documentation

* reprotect and Update bug fixes

* add an alias to avoid breaking change

* Update the azure powershell developer guide with autorest powershell generator related materials

* Update the category.

* change log

* Update syntax in help files.

* Update C# SDK to throw Cloud Exception, Update default SKU to be ST2

* Escape single quote

* add TestGetResourceByNameAndType test for apiversion check

* updating tests and adding completer

* fix changelog merge error

* updating help files and tests

* add breaking changes

* Update files

* Update encoding to UTF8

* Add breaking changes (#11329)

* add breaking changes

* Change useragent to align to Az3.0 modules

* Update Get-AzResourceLock.md

Added an example that uses the -AtScope parameter.

* Update ChangeLog.md

* Consume modified SDK clients.

* Remove unnecessary changes.

* Fix doc

Microsot→Microsoft
add dot

* Add a test case for Save-AzDeploymentScript cmdlet; update test recordings; update help messages; address reviewer comments

* Remove duplicate cmdlet names in Az.Resources.psd1

* Add change log comment

* Update Network SDK & test recordings

* add license header to ArrayExtension.cs

* Update New-AzNetworkInterface.md

Removed reference to the manual subnet entry and added code to allow retrieval of subnetID via PowerShell from Virtual Network.

This would be a best practice rather than hard-coding subnet ID entry.

* Updated error messages and help files.
- Share service provided details for 4xx HTTP status codes
- Updated help file examples to be accurate and consistent

* Update tests, tests records and help files.

* Update New-AzVmss for AutomaticRepairsPolicy issue.

* Update Compute SDK version to 33.0.0

* Updated CosmosDB Management version

* Updated TEE type name VSMEnclave to VBSEnclave

* Updated ChangeLog

* Removed the new version header from ChangeLog

* Added option of Byte encoding for New-AzDataLakeStoreItem, Add-AzDAtaLakeStoreItemContent, Get-AzDAtaLakeStoreItemContent

* Update URLs in help files

* AppGw recordings

* Updated CosmosDB Management SDK version (#11351)

* Updated CosmosDB Management version

* Updated ChangeLog

* Removed the new version header from ChangeLog

Co-authored-by: Meha Kaushik <[email protected]>

* [ASR] [V2A] Adding properties for VMware DR monitoring

* Update

* bump up version

* Fix the bug that RunVerioncontroller.ps1 act different under different directory.

* CredSan suppression

* Update tests file.

* Adding SensitivityRank parameter to DataClassification Set Cmdlets

* Update syntax in help files.

* Consume modified SDK clients.

* Remove unnecessary changes.

* Update tests, tests records and help files.

* Update tests file.

* Update ChangeLog.md

* Update Management.Sql package version

* Add rerun support to create pipeline run cmdlet

* Update changeLog

* Fix

* addressing review comments

* ChangeLog update

* add comment, add byte encoding for auto completion

* 1.Support customers specify min TLS version when creating cluster
2. Update New-AzHDInsightConfig.md

* Added retrying policy update

* updated paramsets and added help file

* Fix after merge

* initial commit for monitor privatelink scope

* initital commit

* Updated cmdlets with disk exclusion parameters

* Added test coverage

* Added ExcludeAllDataDisks Parameter

* Added disk exclusion tests

* updated markdown help

* updated param sets

* fixed tests

* Added unmanaged vm restore warning

* Updated Markdown Help file

* updated tests

* Update README.md

* Fixing bugs and Allowing Gremlin, Cassandra, Table api account creation

* Allow Encryption property to Target parameter of New-AzGalleryImageVersion cmdlet

Add the following parameters to New-AzDiskConfig: DiskIOPSReadOnly, DiskMBpsReadOnly, MaxSharesCount, GalleryImageReference
Fix tempDisk issue

* suppress breaking change issue from int to long

* Update Set-AzApiManagementGroup.md

GroupId is a required parameter, please add this in the example as well.

* Replace Sql client using generic rest client

* Update change log

* Fixing Cassandra schema and Mongo shard key null values

* Adding in ChangeLog

* Updated Help

* add automapper assembly

* Revise according to review

* add mapper

* remove unused util class

* remove incorrect management sdk

* updated param help messages

* add cmdlets for private link scope

* updated markdown help files with examples

* update cmdlet syntax

* Update ChangeLog.md

fix readme

* Polish changelog

* Comment out the exportchildproperties test in aliastest of testfilesystem, and unskip the adlstest.testfilesystem

* Rephrase changelog

* add cmdlets for private link scope scoped resource

* undo unexpected delete

* update access modifier to public for private link related cmdlets

* update access modifier to public for private link related models

* fix cmdlet names

* update to apply new generated SDK

* fix typo

* add monitor provider

* Update ChangeLog.md

Move changelog from version 1.4 to upcoming release.

* fix parameters of private link scope related cmdlets

* update parameters to apply new generated SDK

* change to lowercase

* apply updated SDK

* remove unused cmdlet, change LinkedResourceId to mandatory

* add test cases for private-link-scope

* update test case

* add AutoMapper back

* apply SDK back

* apply SDK back

* add microsoft.insights/privatelinkscopes as provider for private link resource

* cmdlets from Az.Network in Az.Monitor test cases won't work, try add Network SDK as dependency

* add network management client in test controller

* add new generated SDK

* typo

* use new generated SDK

* typo

* upgrade SDK version

* generate help markdown files for private link scope

* remove test nupkg

* fix test

* add recorded test

* fix bad help

* update changelog.md

* try upgrade monitor sdk reference in sql.Test.csproj

* fix test case

* add operational insights to monitor.sln

* typo

* add network into monitor.sln

* add management clients also in playback mode

* test fix

* update record json

* suppress breaking change issues

* rename privatelinkscopescopedresource to privatelinkscopedresource

* record test

* polish changelog.md

* hide private endpoint connection from private link scope

Co-authored-by: aygoya <[email protected]>
Co-authored-by: Yeming Liu <[email protected]>
Co-authored-by: Jason Gilbertson <[email protected]>
Co-authored-by: Filiz Topatan <[email protected]>
Co-authored-by: msJinLei <[email protected]>
Co-authored-by: Dingmeng Xue <[email protected]>
Co-authored-by: Hans De Mulder <[email protected]>
Co-authored-by: Anthony Martin <[email protected]>
Co-authored-by: Sudhindra Kovalam <[email protected]>
Co-authored-by: Chris Eggert <[email protected]>
Co-authored-by: Damien Caro <[email protected]>
Co-authored-by: Yeming Liu <[email protected]>
Co-authored-by: Nilambari <[email protected]>
Co-authored-by: Nilambari <[email protected]>
Co-authored-by: Amol Agarwal <[email protected]>
Co-authored-by: Amol Agarwal <[email protected]>
Co-authored-by: Yunchi Wang <[email protected]>
Co-authored-by: MSSedusch <[email protected]>
Co-authored-by: ayfathim <[email protected]>
Co-authored-by: Xiaogang Ding <[email protected]>
Co-authored-by: bashahee <[email protected]>
Co-authored-by: Teng Lu <[email protected]>
Co-authored-by: shahbj79 <[email protected]>
Co-authored-by: Bhavin Shah <[email protected]>
Co-authored-by: [email protected] <[email protected]>
Co-authored-by: Peter Lorenzen <[email protected]>
Co-authored-by: Ikko Ashimine <[email protected]>
Co-authored-by: erich-wang <[email protected]>
Co-authored-by: Anton Evseev <[email protected]>
Co-authored-by: Thomas Thornton <[email protected]>
Co-authored-by: gkostal <[email protected]>
Co-authored-by: Hyonho Lee <[email protected]>
Co-authored-by: Meha Kaushik <[email protected]>
Co-authored-by: Rahul Dutta <[email protected]>
Co-authored-by: Meha Kaushik <[email protected]>
Co-authored-by: Vidyadhari Jami <[email protected]>
Co-authored-by: wyunchi-ms <[email protected]>
Co-authored-by: bashahee <[email protected]>
Co-authored-by: lijzha <[email protected]>
Co-authored-by: Jin Lei <[email protected]>
Co-authored-by: Zhenyu Zhou <[email protected]>
Co-authored-by: sambitratha <[email protected]>
Co-authored-by: Sambit Rath <[email protected]>
Co-authored-by: erwinkramer <[email protected]>
Co-authored-by: Yeming Liu <[email protected]>
  • Loading branch information
Show file tree
Hide file tree
Showing 37 changed files with 8,569 additions and 14 deletions.
4 changes: 3 additions & 1 deletion src/Monitor/Monitor.Test/Monitor.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Azure.Management.Monitor" Version="0.24.1-preview" />
<PackageReference Include="Microsoft.Azure.Management.Monitor" Version="0.25.0-preview" />
<PackageReference Include="Microsoft.Azure.Management.ApplicationInsights" Version="0.2.0-preview" />
<PackageReference Include="Microsoft.Azure.Management.Network" Version="19.19.0-preview" />
<PackageReference Include="Microsoft.Azure.Management.OperationalInsights" Version="0.19.0-preview" />
</ItemGroup>

<ItemGroup>
Expand Down
31 changes: 31 additions & 0 deletions src/Monitor/Monitor.Test/ScenarioTests/Common.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,35 @@ function Clean-ResourceGroup($rgname)
if ([Microsoft.Azure.Test.HttpRecorder.HttpMockServer]::Mode -ne [Microsoft.Azure.Test.HttpRecorder.HttpRecorderMode]::Playback) {
Remove-AzResourceGroup -Name $rgname -Force
}
}

<#
.SYNOPSIS
Sleeps but only during recording.
#>
function Start-TestSleep($milliseconds)
{
if ((Get-MonitorTestMode) -ne 'Playback')
{
Start-Sleep -Milliseconds $milliseconds
}
}

<#
.SYNOPSIS
Gets test mode - 'Record' or 'Playback'
#>
function Get-MonitorTestMode {
try {
$testMode = [Microsoft.Azure.Test.HttpRecorder.HttpMockServer]::Mode;
$testMode = $testMode.ToString();
} catch {
if ($PSItem.Exception.Message -like '*Unable to find type*') {
$testMode = 'Record';
} else {
throw;
}
}

return $testMode
}
46 changes: 46 additions & 0 deletions src/Monitor/Monitor.Test/ScenarioTests/PrivateLinkScopeTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// ----------------------------------------------------------------------------------
//
// 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 Microsoft.Azure.ServiceManagement.Common.Models;
using Microsoft.WindowsAzure.Commands.ScenarioTest;
using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
using Xunit;

namespace Microsoft.Azure.Commands.Insights.Test.ScenarioTests
{
public class PrivateLinkScopeTests : RMTestBase
{
public XunitTracingInterceptor _logger;

public PrivateLinkScopeTests(Xunit.Abstractions.ITestOutputHelper output)
{
_logger = new XunitTracingInterceptor(output);
XunitTracingInterceptor.AddToContext(_logger);
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestPrivateLinkScopeCRUD()
{
TestsController.NewInstance.RunPsTest(_logger, "Test-PrivateLinkScopeCRUD");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestPrivateLinkScopedResourceCRUD()
{
TestsController.NewInstance.RunPsTest(_logger, "Test-PrivateLinkScopedResourceCRUD");
}
}
}
198 changes: 198 additions & 0 deletions src/Monitor/Monitor.Test/ScenarioTests/PrivateLinkScopeTests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
# ----------------------------------------------------------------------------------
#
# 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.
# ----------------------------------------------------------------------------------

function Test-PrivateLinkScopeCRUD
{
# setup
$rg_name = Get-ResourceGroupName

$scope_name1 = Get-ResourceName
$scope_name2 = Get-ResourceName
$scope_name3 = Get-ResourceName

$config_name = Get-ResourceName
$vnet_name = Get-ResourceName
$connection_name = Get-ResourceName
$endpoint_name = Get-ResourceName

$key1 = "key1"
$key2 = "key2"
$key3 = "key3"

$val1 = "val1"
$val2 = "val2"
$val3 = "val3"

$tag1 = $key1+":"+$val1
$tag2 = $key2+":"+$val2
$tag3 = $key3+":"+$val3

try
{
#create resource group
New-AzResourceGroup -Name $rg_name -Location "westus"

#create private link scope
New-AzInsightsPrivateLinkScope -ResourceGroupName $rg_name -Name $scope_name1 -Location "global"
New-AzInsightsPrivateLinkScope -ResourceGroupName $rg_name -Name $scope_name2 -Location "global"
New-AzInsightsPrivateLinkScope -ResourceGroupName $rg_name -Name $scope_name3 -Location "global"

#get private link scope
$scope1 = Get-AzInsightsPrivateLinkScope -ResourceGroupName $rg_name -Name $scope_name1
$scope2 = Get-AzInsightsPrivateLinkScope -ResourceGroupName $rg_name -Name $scope_name2
$scope3 = Get-AzInsightsPrivateLinkScope -ResourceGroupName $rg_name -Name $scope_name3

Assert-NotNull $scope1
Assert-NotNull $scope2
Assert-NotNull $scope3

Assert-AreEqual $scope_name1 $scope1.Name
Assert-AreEqual $scope_name2 $scope2.Name
Assert-AreEqual $scope_name3 $scope3.Name

Assert-AreEqual "Succeeded" $scope1.ProvisioningState
Assert-AreEqual "Succeeded" $scope2.ProvisioningState
Assert-AreEqual "Succeeded" $scope3.ProvisioningState

#update private link scope
$scope1 = Update-AzInsightsPrivateLinkScope -ResourceGroupName $rg_name -Name $scope_name1 -Tags $tag1
$scope2 = Update-AzInsightsPrivateLinkScope -ResourceId $scope2.Id -Tags $tag2
$scope3 = $scope3 | Update-AzInsightsPrivateLinkScope -Tags $tag3

$valout1 = "abracadabra"
$valout2 = "abracadabra"
$valout3 = "abracadabra"

$scope1.Tags.TryGetValue($key1, [ref]$valout1)
$scope2.Tags.TryGetValue($key2, [ref]$valout2)
$scope3.Tags.TryGetValue($key3, [ref]$valout3)

Assert-AreEqual $val1 $valout1
Assert-AreEqual $val2 $valout2
Assert-AreEqual $val3 $valout3

#get/list private-link-resource
$private_link_resource = Get-AzPrivateLinkResource -PrivateLinkResourceId $scope1.Id

Assert-NotNull $private_link_resource
Assert-AreEqual 'azuremonitor' $private_link_resource[0].GroupId

#create private endpoint connection
$subnetConfig = New-AzVirtualNetworkSubnetConfig -Name $config_name -AddressPrefix "11.0.1.0/24" -PrivateEndpointNetworkPolicies "Disabled"
New-AzVirtualNetwork -ResourceGroupName $rg_name -Name $vnet_name -Location "eastus2euap" -AddressPrefix "11.0.0.0/16" -Subnet $subnetConfig
$vnet=Get-AzVirtualNetwork -Name $vnet_name -ResourceGroupName $rg_name
$plsConnection = New-AzPrivateLinkServiceConnection -Name $connection_name -PrivateLinkServiceId $scope1.Id -GroupId $private_link_resource[0].GroupId
New-AzPrivateEndpoint -ResourceGroupName $rg_name -Name $endpoint_name -Location "eastus2euap" -Subnet $vnet.subnets[0] -PrivateLinkServiceConnection $plsConnection -ByManualRequest

$connection = Get-AzPrivateEndpointConnection -PrivateLinkResourceId $scope1.Id

Assert-NotNull $connection
Assert-AreEqual "Pending" $connection.PrivateLinkServiceConnectionState.Status

$connectionApprove = Approve-AzPrivateEndpointConnection -ResourceId $connection.Id
Assert-NotNull $connectionApprove;
Assert-AreEqual "Approved" $connectionApprove.PrivateLinkServiceConnectionState.Status

Start-TestSleep 20000

$connectionRemove = Remove-AzPrivateEndpointConnection -ResourceId $connection.Id -PassThru -Force
Assert-AreEqual true $connectionRemove

Start-TestSleep 15000

$connection2 = Get-AzPrivateEndpointConnection -PrivateLinkResourceId $scope1.Id
Assert-Null $connection2

#delete private link scope
$delete1 = Remove-AzInsightsPrivateLinkScope -ResourceGroupName $rg_name -Name $scope_name1
$delete2 = Remove-AzInsightsPrivateLinkScope -ResourceId $scope2.Id
$delete3 = $scope3 | Remove-AzInsightsPrivateLinkScope

Assert-AreEqual true $delete1
Assert-AreEqual true $delete2
Assert-AreEqual true $delete3
}
catch
{
throw $_;
}
finally
{
# Cleanup
Clean-ResourceGroup $rg_name;
}
}

function Test-PrivateLinkScopedResourceCRUD
{
# setup
$rg_name = Get-ResourceGroupName

$scope_name1 = Get-ResourceName
$scope_name2 = Get-ResourceName

$la_name = Get-ResourceName
$ai_name = Get-ResourceName

$scoped_resource_name1 = Get-ResourceName
$scoped_resource_name2 = Get-ResourceName

try
{
#create resource group
New-AzResourceGroup -Name $rg_name -Location "westus"

#create private link scope
New-AzInsightsPrivateLinkScope -ResourceGroupName $rg_name -Name $scope_name1 -Location "global"
New-AzInsightsPrivateLinkScope -ResourceGroupName $rg_name -Name $scope_name2 -Location "global"

#create LA workspace
$la = New-AzOperationalInsightsWorkspace -ResourceGroupName $rg_name -Name $la_name -Location "eastus"

#create AI component
$ai = New-AzApplicationInsights -ResourceGroupName $rg_name -Name $ai_name -Location "eastus"

#create scoped resource for AI/LA
New-AzInsightsPrivateLinkScopedResource -LinkedResourceId $ai.Id -ResourceGroupName $rg_name -ScopeName $scope_name1 -Name $scoped_resource_name1
New-AzInsightsPrivateLinkScopedResource -LinkedResourceId $la.ResourceId -ResourceGroupName $rg_name -ScopeName $scope_name2 -Name $scoped_resource_name2

#get scoped resource
$scoped_resource1 = Get-AzInsightsPrivateLinkScopedResource -ResourceGroupName $rg_name -ScopeName $scope_name1 -Name $scoped_resource_name1
$scoped_resource2 = Get-AzInsightsPrivateLinkScopedResource -ResourceGroupName $rg_name -ScopeName $scope_name2 -Name $scoped_resource_name2

Assert-NotNull $scoped_resource1
Assert-NotNull $scoped_resource2
Assert-AreEqual $ai.Id $scoped_resource1.LinkedResourceId
Assert-AreEqual $la.ResourceId $scoped_resource2.LinkedResourceId

#delete scoped resource
$delete1 = Remove-AzInsightsPrivateLinkScopedResource -ResourceGroupName $rg_name -ScopeName $scope_name1 -Name $scoped_resource_name1
$delete2 = Remove-AzInsightsPrivateLinkScopedResource -ResourceGroupName $rg_name -ScopeName $scope_name2 -Name $scoped_resource_name2

Assert-AreEqual true $delete1
Assert-AreEqual true $delete2

Remove-AzInsightsPrivateLinkScope -ResourceGroupName $rg_name -Name $scope_name1
Remove-AzInsightsPrivateLinkScope -ResourceGroupName $rg_name -Name $scope_name2
}
catch
{
throw $_
}
finally
{
# Cleanup
Clean-ResourceGroup $rg_name;
}
}
Loading

0 comments on commit bc344da

Please sign in to comment.