Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
36 changes: 36 additions & 0 deletions src/Network/Network.Test/ScenarioTests/AvailableAliasTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// ----------------------------------------------------------------------------------
//
// 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.Commands.Network.Test.ScenarioTests;
using Microsoft.WindowsAzure.Commands.ScenarioTest;
using Xunit;

namespace Commands.Network.Test.ScenarioTests
{
public class AvailableAliasTests :NetworkTestRunner
{
public AvailableAliasTests(Xunit.Abstractions.ITestOutputHelper output)
: base(output)
{
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
[Trait(Category.Owner, NrpTeamAlias.sdnnrp)]
public void TestAvailableAliasList()
{
TestRunner.RunTestScript( "Test-GetAvailableAliasList");
}
}
}
33 changes: 33 additions & 0 deletions src/Network/Network.Test/ScenarioTests/AvailableAliasTests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# ----------------------------------------------------------------------------------
#
# 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.
# ----------------------------------------------------------------------------------

<#
.SYNOPSIS
Tests checking API to list available Alias.
#>
function Test-GetAvailableAliasList
{
$location = Get-ProviderLocation ResourceManagement

try
{
$results = Get-AzAvailableServiceAlias -Location $location;
Assert-NotNull $results;
}
finally
{
# Cleanup
Clean-ResourceGroup $rgname
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
{
"Entries": [
{
"RequestUri": "/subscriptions/947d47b4-7883-4bb9-9d85-c5e8e2f572ce/providers/Microsoft.Network/locations/West%20Central%20US/availableServiceAliases?api-version=2019-08-01",
"EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvOTQ3ZDQ3YjQtNzg4My00YmI5LTlkODUtYzVlOGUyZjU3MmNlL3Byb3ZpZGVycy9NaWNyb3NvZnQuTmV0d29yay9sb2NhdGlvbnMvV2VzdCUyMENlbnRyYWwlMjBVUy9hdmFpbGFibGVTZXJ2aWNlQWxpYXNlcz9hcGktdmVyc2lvbj0yMDE5LTA4LTAx",
"RequestMethod": "GET",
"RequestBody": "",
"RequestHeaders": {
"x-ms-client-request-id": [
"bb89b196-039e-470b-9c61-c5e3b7a8ad20"
],
"Accept-Language": [
"en-US"
],
"User-Agent": [
"FxVersion/4.6.27817.01",
"OSName/Windows",
"OSVersion/Microsoft.Windows.10.0.18362.",
"Microsoft.Azure.Management.Network.NetworkManagementClient/19.16.0.0"
]
},
"ResponseHeaders": {
"Cache-Control": [
"no-cache"
],
"Pragma": [
"no-cache"
],
"x-ms-request-id": [
"32791b33-78e3-4611-8d4f-91fdce3eac56"
],
"x-ms-correlation-request-id": [
"cf783df8-e0a8-4743-9b55-98a450937f2a"
],
"x-ms-arm-service-request-id": [
"138ace78-6c17-4b70-8794-bf455e2f1f53"
],
"Strict-Transport-Security": [
"max-age=31536000; includeSubDomains"
],
"Server": [
"Microsoft-HTTPAPI/2.0",
"Microsoft-HTTPAPI/2.0"
],
"x-ms-ratelimit-remaining-subscription-reads": [
"11999"
],
"x-ms-routing-request-id": [
"WESTUS:20191004T202417Z:cf783df8-e0a8-4743-9b55-98a450937f2a"
],
"X-Content-Type-Options": [
"nosniff"
],
"Date": [
"Fri, 04 Oct 2019 20:24:16 GMT"
],
"Content-Length": [
"632"
],
"Content-Type": [
"application/json; charset=utf-8"
],
"Expires": [
"-1"
]
},
"ResponseBody": "{\r\n \"value\": [\r\n {\r\n \"name\": \"servicesAzure\",\r\n \"id\": \"/subscriptions/947d47b4-7883-4bb9-9d85-c5e8e2f572ce/providers/Microsoft.Network/AvailableServiceAliases/servicesAzure\",\r\n \"type\": \"Microsoft.Network/AvailableServiceAliases\",\r\n \"resourceName\": \"/services/Azure\"\r\n },\r\n {\r\n \"name\": \"servicesAzureManagedInstance\",\r\n \"id\": \"/subscriptions/947d47b4-7883-4bb9-9d85-c5e8e2f572ce/providers/Microsoft.Network/AvailableServiceAliases/servicesAzureManagedInstance\",\r\n \"type\": \"Microsoft.Network/AvailableServiceAliases\",\r\n \"resourceName\": \"/services/Azure/ManagedInstance\"\r\n }\r\n ]\r\n}",
"StatusCode": 200
}
],
"Names": {},
"Variables": {
"SubscriptionId": "947d47b4-7883-4bb9-9d85-c5e8e2f572ce"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
//
// Copyright (c) Microsoft and contributors. All rights reserved.
//
// 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.Collections.Generic;
using System.Management.Automation;
using Microsoft.Azure.Commands.Network.Models;
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
using Microsoft.Azure.Management.Network;
using CNM = Microsoft.Azure.Commands.Network.Models;

namespace Microsoft.Azure.Commands.Network.Automation
{
[Cmdlet("Get", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "AvailableServiceAlias"), OutputType(typeof(PsAvailableServiceAlias))]
public partial class GetAzureAvailableServiceAliasCommand : NetworkBaseCmdlet
{
[Parameter(
Mandatory = true,
HelpMessage = "The location.",
ValueFromPipelineByPropertyName = true)]
[LocationCompleter("Microsoft.Network/locations/availableServiceAliases")]
[ValidateNotNullOrEmpty]
public string Location { get; set; }

public override void Execute()
{
base.Execute();

var availableServiceAliasList = this.NetworkClient.NetworkManagementClient.AvailableServiceAliases.List(Location);
List<PsAvailableServiceAlias> psAvailableServiceAlias = new List<PsAvailableServiceAlias>();

foreach (var availableServiceAlias in availableServiceAliasList)
{
psAvailableServiceAlias.Add(NetworkResourceManagerProfile.Mapper.Map<CNM.PsAvailableServiceAlias>(availableServiceAlias));
}

WriteObject(psAvailableServiceAlias, true);
}
}
}
1 change: 1 addition & 0 deletions src/Network/Network/Az.Network.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,7 @@ CmdletsToExport = 'Add-AzApplicationGatewayAuthenticationCertificate',
'Deny-AzPrivateEndpointConnection',
'Get-AzAvailablePrivateEndpointType',
'Get-AzAvailablePrivateEndpointType',
'Get-AzAvailableServiceAlias',
'New-AzBastion', 'Get-AzBastion', 'Remove-AzBastion',
'Start-AzVirtualNetworkGatewayPacketCapture',
'Stop-AzVirtualNetworkGatewayPacketCapture',
Expand Down
1 change: 1 addition & 0 deletions src/Network/Network/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
--->

## Upcoming Release
* Add new cmdlet Get-AzAvailableServiceAlias which can be called to get the aliases that can be used for Service Endpoint Policies.
* Added support for the adding traffic selectors to Virtual Network Gateway Connections
- New cmdlets added:
- New-AzureRmTrafficSelectorPolicy
Expand Down
7 changes: 7 additions & 0 deletions src/Network/Network/Common/NetworkResourceManagerProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,13 @@ private static void Initialize()
// MNM to CNM
cfg.CreateMap<MNM.AvailableDelegation, CNM.PSAvailableDelegation>();

// Available subnet aliases
// CNM to MNM
cfg.CreateMap<CNM.PsAvailableServiceAlias, MNM.AvailableServiceAlias>();

// MNM to CNM
cfg.CreateMap<MNM.AvailableServiceAlias, CNM.PsAvailableServiceAlias>();

// VirtualNetwork Peering
// CNM to MNM
cfg.CreateMap<CNM.PSVirtualNetworkPeering, MNM.VirtualNetworkPeering>()
Expand Down
18 changes: 18 additions & 0 deletions src/Network/Network/Models/PSAvailableServiceAlias.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System.Collections.Generic;
using Microsoft.WindowsAzure.Commands.Common.Attributes;

namespace Microsoft.Azure.Commands.Network.Models
{
public class PsAvailableServiceAlias
{
[Ps1Xml(Label = "Name", Target = ViewControl.Table, Position = 1)]
public string Name { get; set; }

public string Id { get; set; }

[Ps1Xml(Target = ViewControl.Table)]
public string Type { get; set; }

public string ResourceName { get; set; }
}
}
3 changes: 3 additions & 0 deletions src/Network/Network/help/Az.Network.md
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,9 @@ Gets an array of private link service id that can be linked to a private end poi
### [Get-AzAvailablePrivateEndpointType](Get-AzAvailablePrivateEndpointType.md)
Return available private end point types in the location

### [Get-AzAvailableServiceAlias](Get-AzAvailableServiceAlias.md)
Get available service aliases in the region.

### [Get-AzAvailableServiceDelegation](Get-AzAvailableServiceDelegation.md)
Get available service delegations in the region.

Expand Down
80 changes: 80 additions & 0 deletions src/Network/Network/help/Get-AzAvailableServiceAlias.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
---
external help file: Microsoft.Azure.PowerShell.Cmdlets.Network.dll-Help.xml
Module Name: Az.Network
online version: https://docs.microsoft.com/en-us/powershell/module/az.network/get-azavailableservicealias
schema: 2.0.0
---

# Get-AzAvailableServiceAlias

## SYNOPSIS
Get available service aliases in the region.

## SYNTAX

```
Get-AzAvailableServiceAlias -Location <String> [-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
```

## DESCRIPTION
The **Get-AzAvailableServiceAlias** cmdlet allows you to retrieve all of the available service aliases for a subnet in the provided location.

## EXAMPLES

### Example 1
```powershell
PS C:\> Get-AzAvailableServiceAliases -Location "westus"

Name Id Type ResourceName
---- -- ---- ------------
servicesAzure /subscriptions/61dc4623-b5f8-41a0-acfc-29537dcf6e5d/providers/Microsoft.Network/AvailableServiceAliases/servicesAzure Microsoft.Network/AvailableServiceAliases /services/Azure
servicesAzureManagedInstance /subscriptions/61dc4623-b5f8-41a0-acfc-29537dcf6e5d/providers/Microsoft.Network/AvailableServiceAliases/servicesAzureManagedInstance Microsoft.Network/AvailableServiceAliases /services/Azure/ManagedInstance

```

## PARAMETERS

### -DefaultProfile
The credentials, account, tenant, and subscription used for communication with Azure.

```yaml
Type: Microsoft.Azure.Commands.Common.Authentication.Abstractions.Core.IAzureContextContainer
Parameter Sets: (All)
Aliases: AzContext, AzureRmContext, AzureCredential

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -Location
The location.

```yaml
Type: System.String
Parameter Sets: (All)
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
```

### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).

## INPUTS

### System.String

## OUTPUTS

### Microsoft.Azure.Commands.Network.Models.PsAvailableServiceAlias

## NOTES

## RELATED LINKS