Skip to content

Commit a5f68d2

Browse files
authored
Merge pull request #10198 from jkhurana19/usr/jakhuran/mergeGetAvailableServiceAlias
Add Get-AzAvailableServiceAlias cmdlet.
2 parents 1179302 + 11ee14a commit a5f68d2

File tree

10 files changed

+306
-0
lines changed

10 files changed

+306
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using Microsoft.Azure.Commands.Network.Test.ScenarioTests;
16+
using Microsoft.WindowsAzure.Commands.ScenarioTest;
17+
using Xunit;
18+
19+
namespace Commands.Network.Test.ScenarioTests
20+
{
21+
public class AvailableAliasTests :NetworkTestRunner
22+
{
23+
public AvailableAliasTests(Xunit.Abstractions.ITestOutputHelper output)
24+
: base(output)
25+
{
26+
}
27+
28+
[Fact]
29+
[Trait(Category.AcceptanceType, Category.CheckIn)]
30+
[Trait(Category.Owner, NrpTeamAlias.sdnnrp)]
31+
public void TestAvailableAliasList()
32+
{
33+
TestRunner.RunTestScript( "Test-GetAvailableAliasList");
34+
}
35+
}
36+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# ----------------------------------------------------------------------------------
2+
#
3+
# Copyright Microsoft Corporation
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
# ----------------------------------------------------------------------------------
14+
15+
<#
16+
.SYNOPSIS
17+
Tests checking API to list available Alias.
18+
#>
19+
function Test-GetAvailableAliasList
20+
{
21+
$location = Get-ProviderLocation ResourceManagement
22+
23+
try
24+
{
25+
$results = Get-AzAvailableServiceAlias -Location $location;
26+
Assert-NotNull $results;
27+
}
28+
finally
29+
{
30+
# Cleanup
31+
Clean-ResourceGroup $rgname
32+
}
33+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
{
2+
"Entries": [
3+
{
4+
"RequestUri": "/subscriptions/947d47b4-7883-4bb9-9d85-c5e8e2f572ce/providers/Microsoft.Network/locations/West%20Central%20US/availableServiceAliases?api-version=2019-08-01",
5+
"EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvOTQ3ZDQ3YjQtNzg4My00YmI5LTlkODUtYzVlOGUyZjU3MmNlL3Byb3ZpZGVycy9NaWNyb3NvZnQuTmV0d29yay9sb2NhdGlvbnMvV2VzdCUyMENlbnRyYWwlMjBVUy9hdmFpbGFibGVTZXJ2aWNlQWxpYXNlcz9hcGktdmVyc2lvbj0yMDE5LTA4LTAx",
6+
"RequestMethod": "GET",
7+
"RequestBody": "",
8+
"RequestHeaders": {
9+
"x-ms-client-request-id": [
10+
"bb89b196-039e-470b-9c61-c5e3b7a8ad20"
11+
],
12+
"Accept-Language": [
13+
"en-US"
14+
],
15+
"User-Agent": [
16+
"FxVersion/4.6.27817.01",
17+
"OSName/Windows",
18+
"OSVersion/Microsoft.Windows.10.0.18362.",
19+
"Microsoft.Azure.Management.Network.NetworkManagementClient/19.16.0.0"
20+
]
21+
},
22+
"ResponseHeaders": {
23+
"Cache-Control": [
24+
"no-cache"
25+
],
26+
"Pragma": [
27+
"no-cache"
28+
],
29+
"x-ms-request-id": [
30+
"32791b33-78e3-4611-8d4f-91fdce3eac56"
31+
],
32+
"x-ms-correlation-request-id": [
33+
"cf783df8-e0a8-4743-9b55-98a450937f2a"
34+
],
35+
"x-ms-arm-service-request-id": [
36+
"138ace78-6c17-4b70-8794-bf455e2f1f53"
37+
],
38+
"Strict-Transport-Security": [
39+
"max-age=31536000; includeSubDomains"
40+
],
41+
"Server": [
42+
"Microsoft-HTTPAPI/2.0",
43+
"Microsoft-HTTPAPI/2.0"
44+
],
45+
"x-ms-ratelimit-remaining-subscription-reads": [
46+
"11999"
47+
],
48+
"x-ms-routing-request-id": [
49+
"WESTUS:20191004T202417Z:cf783df8-e0a8-4743-9b55-98a450937f2a"
50+
],
51+
"X-Content-Type-Options": [
52+
"nosniff"
53+
],
54+
"Date": [
55+
"Fri, 04 Oct 2019 20:24:16 GMT"
56+
],
57+
"Content-Length": [
58+
"632"
59+
],
60+
"Content-Type": [
61+
"application/json; charset=utf-8"
62+
],
63+
"Expires": [
64+
"-1"
65+
]
66+
},
67+
"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}",
68+
"StatusCode": 200
69+
}
70+
],
71+
"Names": {},
72+
"Variables": {
73+
"SubscriptionId": "947d47b4-7883-4bb9-9d85-c5e8e2f572ce"
74+
}
75+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
//
2+
// Copyright (c) Microsoft and contributors. All rights reserved.
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
//
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
//
16+
17+
using System.Collections.Generic;
18+
using System.Management.Automation;
19+
using Microsoft.Azure.Commands.Network.Models;
20+
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
21+
using Microsoft.Azure.Management.Network;
22+
using CNM = Microsoft.Azure.Commands.Network.Models;
23+
24+
namespace Microsoft.Azure.Commands.Network.Automation
25+
{
26+
[Cmdlet("Get", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "AvailableServiceAlias"), OutputType(typeof(PsAvailableServiceAlias))]
27+
public partial class GetAzureAvailableServiceAliasCommand : NetworkBaseCmdlet
28+
{
29+
[Parameter(
30+
Mandatory = true,
31+
HelpMessage = "The location.",
32+
ValueFromPipelineByPropertyName = true)]
33+
[LocationCompleter("Microsoft.Network/locations/availableServiceAliases")]
34+
[ValidateNotNullOrEmpty]
35+
public string Location { get; set; }
36+
37+
public override void Execute()
38+
{
39+
base.Execute();
40+
41+
var availableServiceAliasList = this.NetworkClient.NetworkManagementClient.AvailableServiceAliases.List(Location);
42+
List<PsAvailableServiceAlias> psAvailableServiceAlias = new List<PsAvailableServiceAlias>();
43+
44+
foreach (var availableServiceAlias in availableServiceAliasList)
45+
{
46+
psAvailableServiceAlias.Add(NetworkResourceManagerProfile.Mapper.Map<CNM.PsAvailableServiceAlias>(availableServiceAlias));
47+
}
48+
49+
WriteObject(psAvailableServiceAlias, true);
50+
}
51+
}
52+
}

src/Network/Network/Az.Network.psd1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,7 @@ CmdletsToExport = 'Add-AzApplicationGatewayAuthenticationCertificate',
416416
'Deny-AzPrivateEndpointConnection',
417417
'Get-AzAvailablePrivateEndpointType',
418418
'Get-AzAvailablePrivateEndpointType',
419+
'Get-AzAvailableServiceAlias',
419420
'New-AzBastion', 'Get-AzBastion', 'Remove-AzBastion',
420421
'Start-AzVirtualNetworkGatewayPacketCapture',
421422
'Stop-AzVirtualNetworkGatewayPacketCapture',

src/Network/Network/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
--->
2020

2121
## Upcoming Release
22+
* Add new cmdlet Get-AzAvailableServiceAlias which can be called to get the aliases that can be used for Service Endpoint Policies.
2223
* Added support for the adding traffic selectors to Virtual Network Gateway Connections
2324
- New cmdlets added:
2425
- New-AzureRmTrafficSelectorPolicy

src/Network/Network/Common/NetworkResourceManagerProfile.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,13 @@ private static void Initialize()
232232
// MNM to CNM
233233
cfg.CreateMap<MNM.AvailableDelegation, CNM.PSAvailableDelegation>();
234234

235+
// Available subnet aliases
236+
// CNM to MNM
237+
cfg.CreateMap<CNM.PsAvailableServiceAlias, MNM.AvailableServiceAlias>();
238+
239+
// MNM to CNM
240+
cfg.CreateMap<MNM.AvailableServiceAlias, CNM.PsAvailableServiceAlias>();
241+
235242
// VirtualNetwork Peering
236243
// CNM to MNM
237244
cfg.CreateMap<CNM.PSVirtualNetworkPeering, MNM.VirtualNetworkPeering>()
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using System.Collections.Generic;
2+
using Microsoft.WindowsAzure.Commands.Common.Attributes;
3+
4+
namespace Microsoft.Azure.Commands.Network.Models
5+
{
6+
public class PsAvailableServiceAlias
7+
{
8+
[Ps1Xml(Label = "Name", Target = ViewControl.Table, Position = 1)]
9+
public string Name { get; set; }
10+
11+
public string Id { get; set; }
12+
13+
[Ps1Xml(Target = ViewControl.Table)]
14+
public string Type { get; set; }
15+
16+
public string ResourceName { get; set; }
17+
}
18+
}

src/Network/Network/help/Az.Network.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,9 @@ Gets an array of private link service id that can be linked to a private end poi
230230
### [Get-AzAvailablePrivateEndpointType](Get-AzAvailablePrivateEndpointType.md)
231231
Return available private end point types in the location
232232

233+
### [Get-AzAvailableServiceAlias](Get-AzAvailableServiceAlias.md)
234+
Get available service aliases in the region.
235+
233236
### [Get-AzAvailableServiceDelegation](Get-AzAvailableServiceDelegation.md)
234237
Get available service delegations in the region.
235238

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
---
2+
external help file: Microsoft.Azure.PowerShell.Cmdlets.Network.dll-Help.xml
3+
Module Name: Az.Network
4+
online version: https://docs.microsoft.com/en-us/powershell/module/az.network/get-azavailableservicealias
5+
schema: 2.0.0
6+
---
7+
8+
# Get-AzAvailableServiceAlias
9+
10+
## SYNOPSIS
11+
Get available service aliases in the region.
12+
13+
## SYNTAX
14+
15+
```
16+
Get-AzAvailableServiceAlias -Location <String> [-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
17+
```
18+
19+
## DESCRIPTION
20+
The **Get-AzAvailableServiceAlias** cmdlet allows you to retrieve all of the available service aliases for a subnet in the provided location.
21+
22+
## EXAMPLES
23+
24+
### Example 1
25+
```powershell
26+
PS C:\> Get-AzAvailableServiceAliases -Location "westus"
27+
28+
Name Id Type ResourceName
29+
---- -- ---- ------------
30+
servicesAzure /subscriptions/61dc4623-b5f8-41a0-acfc-29537dcf6e5d/providers/Microsoft.Network/AvailableServiceAliases/servicesAzure Microsoft.Network/AvailableServiceAliases /services/Azure
31+
servicesAzureManagedInstance /subscriptions/61dc4623-b5f8-41a0-acfc-29537dcf6e5d/providers/Microsoft.Network/AvailableServiceAliases/servicesAzureManagedInstance Microsoft.Network/AvailableServiceAliases /services/Azure/ManagedInstance
32+
33+
```
34+
35+
## PARAMETERS
36+
37+
### -DefaultProfile
38+
The credentials, account, tenant, and subscription used for communication with Azure.
39+
40+
```yaml
41+
Type: Microsoft.Azure.Commands.Common.Authentication.Abstractions.Core.IAzureContextContainer
42+
Parameter Sets: (All)
43+
Aliases: AzContext, AzureRmContext, AzureCredential
44+
45+
Required: False
46+
Position: Named
47+
Default value: None
48+
Accept pipeline input: False
49+
Accept wildcard characters: False
50+
```
51+
52+
### -Location
53+
The location.
54+
55+
```yaml
56+
Type: System.String
57+
Parameter Sets: (All)
58+
Aliases:
59+
60+
Required: True
61+
Position: Named
62+
Default value: None
63+
Accept pipeline input: True (ByPropertyName)
64+
Accept wildcard characters: False
65+
```
66+
67+
### CommonParameters
68+
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).
69+
70+
## INPUTS
71+
72+
### System.String
73+
74+
## OUTPUTS
75+
76+
### Microsoft.Azure.Commands.Network.Models.PsAvailableServiceAlias
77+
78+
## NOTES
79+
80+
## RELATED LINKS

0 commit comments

Comments
 (0)