Skip to content

Commit 8fa9990

Browse files
committed
Merge branch 'network-november-release' of github.com:akshaysngupta/azure-powershell into fig-ag
2 parents 7217306 + 8956f42 commit 8fa9990

16 files changed

+738
-445
lines changed

src/ResourceManager/Network/Commands.Network.Test/ScenarioTests/ApplicationGatewayTests.ps1

Lines changed: 446 additions & 419 deletions
Large diffs are not rendered by default.

src/ResourceManager/Network/Commands.Network.Test/ScenarioTests/Common.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ Cleans the created resource groups
9393
function Clean-ResourceGroup($rgname)
9494
{
9595
if ((Get-NetworkTestMode) -ne 'Playback') {
96-
Remove-AzureRmResourceGroup -Name $rgname -Force
96+
Remove-AzResourceGroup -Name $rgname -Force
9797
}
9898
}
9999

src/ResourceManager/Network/Commands.Network/ApplicationGateway/NewAzureApplicationGatewayCommand.cs

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
using AutoMapper;
15+
using Microsoft.Azure.Commands.ManagedServiceIdentity.Models;
1616
using Microsoft.Azure.Commands.Network.Models;
1717
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
1818
using Microsoft.Azure.Commands.ResourceManager.Common.Tags;
@@ -183,6 +183,20 @@ public class NewAzureApplicationGatewayCommand : ApplicationGatewayBaseCmdlet
183183
HelpMessage = "A hashtable which represents resource tags.")]
184184
public Hashtable Tag { get; set; }
185185

186+
[Parameter(
187+
Mandatory = false,
188+
ValueFromPipelineByPropertyName = true,
189+
HelpMessage = "ResourceId of the user assigned identity to be assigned to Application Gateway.")]
190+
[ValidateNotNullOrEmpty]
191+
public string UserAssignedIdentityId { get; set; }
192+
193+
[Parameter(
194+
Mandatory = false,
195+
ValueFromPipelineByPropertyName = true,
196+
HelpMessage = "user assigned identity to be assigned to Application Gateway.")]
197+
[ValidateNotNullOrEmpty]
198+
public PsUserAssignedIdentity UserAssignedIdentity { get; set; }
199+
186200
[Parameter(
187201
Mandatory = false,
188202
HelpMessage = "Do not ask for confirmation if you want to overrite a resource")]
@@ -322,6 +336,23 @@ private PSApplicationGateway CreateApplicationGateway()
322336
applicationGateway.Zones = this.Zone?.ToList();
323337
}
324338

339+
if (this.UserAssignedIdentity != null)
340+
{
341+
this.UserAssignedIdentityId = this.UserAssignedIdentity.Id;
342+
}
343+
344+
if (this.UserAssignedIdentityId != null)
345+
{
346+
applicationGateway.Identity = new PSManagedServiceIdentity
347+
{
348+
Type = MNM.ResourceIdentityType.UserAssigned,
349+
UserAssignedIdentities = new Dictionary<string, PSManagedServiceIdentityUserAssignedIdentitiesValue>
350+
{
351+
{ this.UserAssignedIdentityId, new PSManagedServiceIdentityUserAssignedIdentitiesValue() }
352+
}
353+
};
354+
}
355+
325356
if (this.CustomErrorConfiguration != null)
326357
{
327358
applicationGateway.CustomErrorConfigurations = this.CustomErrorConfiguration?.ToList();

src/ResourceManager/Network/Commands.Network/ApplicationGateway/SslCertificate/AzureApplicationGatewaySslCertificateBase.cs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,24 +29,36 @@ public class AzureApplicationGatewaySslCertificateBase : NetworkBaseCmdlet
2929
public string Name { get; set; }
3030

3131
[Parameter(
32-
Mandatory = true,
32+
Mandatory = false,
3333
HelpMessage = "Path of certificate PFX file")]
3434
[ValidateNotNullOrEmpty]
3535
public string CertificateFile { get; set; }
3636

3737
[Parameter(
38-
Mandatory = true,
38+
Mandatory = false,
3939
HelpMessage = "Certificate password")]
4040
[ValidateNotNullOrEmpty]
4141
public SecureString Password { get; set; }
4242

43+
[Parameter(
44+
Mandatory = false,
45+
HelpMessage = "SecretId (uri) of the KeyVault Secret. Use this option when a specific version of secret needs to be used.")]
46+
[ValidateNotNullOrEmpty]
47+
public string KeyVaultSecretId { get; set; }
48+
4349
public PSApplicationGatewaySslCertificate NewObject()
4450
{
4551
var sslCertificate = new PSApplicationGatewaySslCertificate();
4652

4753
sslCertificate.Name = this.Name;
48-
sslCertificate.Data = Convert.ToBase64String(File.ReadAllBytes(this.CertificateFile));
49-
sslCertificate.Password = this.Password;
54+
if (this.CertificateFile != null)
55+
{
56+
sslCertificate.Data = Convert.ToBase64String(File.ReadAllBytes(this.CertificateFile));
57+
sslCertificate.Password = this.Password;
58+
}
59+
60+
sslCertificate.KeyVaultSecretId = this.KeyVaultSecretId;
61+
5062
sslCertificate.Id =
5163
ApplicationGatewayChildResourceHelper.GetResourceNotSetId(
5264
this.NetworkClient.NetworkManagementClient.SubscriptionId,

src/ResourceManager/Network/Commands.Network/ChangeLog.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,10 @@
4040
- New-AzureRmApplicationGatewayUrlPathMapConfig
4141
* Removed deprecated -ResourceId parameter from Get-AzServiceEndpointPolicyDefinition
4242
* Removed deprecated EnableVmProtection property from PSVirtualNetwork
43-
* Removed deprecated Set-AzVirtualNetworkGatewayVpnClientConfig cmdlet
43+
* Removed deprecated Set-AzVirtualNetworkGatewayVpnClientConfig cmdlet
44+
* Added KeyVault Support to Application Gateway using Identity.
45+
- Cmdlets updated with optonal parameter -KeyVaultSecretId, -KeyVaultSecret
46+
- Add-AzApplicationGatewaySslCertificate
47+
- New-AzApplicationGatewaySslCertificate
48+
- Set-AzApplicationGatewaySslCertificate
49+
- New-AzApplicationGateway cmdlet updated with optional parameter -UserAssignedIdentityId, -UserAssignedIdentity

src/ResourceManager/Network/Commands.Network/Commands.Network.Netcore.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,8 @@
6868
<ItemGroup>
6969
<Content Include="help\**\*" CopyToOutputDirectory="PreserveNewest" />
7070
</ItemGroup>
71+
72+
<ItemGroup>
73+
<ProjectReference Include="..\..\ManagedServiceIdentity\Commands.ManagedServiceIdentity\Commands.ManagedServiceIdentity.Netcore.csproj" />
74+
</ItemGroup>
7175
</Project>

src/ResourceManager/Network/Commands.Network/Common/NetworkResourceManagerProfile.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ private static void Initialize()
5656
cfg.CreateMap<CNM.PSResourceId, MNM.SubResource>();
5757
cfg.CreateMap<MNM.SubResource, CNM.PSResourceId>();
5858

59+
// Managed Service Identity
60+
cfg.CreateMap<CNM.PSManagedServiceIdentity, MNM.ManagedServiceIdentity>();
61+
cfg.CreateMap<MNM.ManagedServiceIdentity, CNM.PSManagedServiceIdentity>();
62+
cfg.CreateMap<CNM.PSManagedServiceIdentityUserAssignedIdentitiesValue, MNM.ManagedServiceIdentityUserAssignedIdentitiesValue>();
63+
cfg.CreateMap<MNM.ManagedServiceIdentityUserAssignedIdentitiesValue, CNM.PSManagedServiceIdentityUserAssignedIdentitiesValue>();
64+
5965
// Route Filter
6066
cfg.CreateMap<CNM.PSRouteFilter, MNM.RouteFilter>();
6167
cfg.CreateMap<MNM.RouteFilter, CNM.PSRouteFilter>();

src/ResourceManager/Network/Commands.Network/Models/PSApplicationGateway.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ public class PSApplicationGateway : PSTopLevelResource
7575
[Ps1Xml(Target = ViewControl.Table)]
7676
public string ProvisioningState { get; set; }
7777

78+
[Ps1Xml(Target = ViewControl.Table)]
79+
public PSManagedServiceIdentity Identity { get; set; }
80+
7881
[JsonIgnore]
7982
public string GatewayIpConfigurationsText
8083
{

src/ResourceManager/Network/Commands.Network/Models/PSApplicationGatewaySslCertificate.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public class PSApplicationGatewaySslCertificate : PSChildResource
2323
public string Data { get; set; }
2424
public SecureString Password { get; set; }
2525
public string PublicCertData { get; set; }
26+
public string KeyVaultSecretId { get; set; }
2627
[Ps1Xml(Target = ViewControl.Table)]
2728
public string ProvisioningState { get; set; }
2829
public string Type { get; set; }
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
//
2+
// Copyright (c) Microsoft. 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+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
//
15+
16+
using Microsoft.Azure.Management.Network.Models;
17+
using Microsoft.WindowsAzure.Commands.Common.Attributes;
18+
using System.Collections.Generic;
19+
20+
namespace Microsoft.Azure.Commands.Network.Models
21+
{
22+
public class PSManagedServiceIdentity
23+
{
24+
[Ps1Xml(Target = ViewControl.Table)]
25+
public ResourceIdentityType? Type { get; set; }
26+
[Ps1Xml(Target = ViewControl.Table)]
27+
public string PrincipalId { get; set; }
28+
[Ps1Xml(Target = ViewControl.Table)]
29+
public string TenantId { get; set; }
30+
[Ps1Xml(Target = ViewControl.Table)]
31+
public Dictionary<string, PSManagedServiceIdentityUserAssignedIdentitiesValue> UserAssignedIdentities { get; set; }
32+
}
33+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//
2+
// Copyright (c) Microsoft. 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+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
//
15+
16+
using Microsoft.WindowsAzure.Commands.Common.Attributes;
17+
18+
namespace Microsoft.Azure.Commands.Network.Models
19+
{
20+
public class PSManagedServiceIdentityUserAssignedIdentitiesValue
21+
{
22+
[Ps1Xml(Target = ViewControl.Table)]
23+
public string PrincipalId { get; set; }
24+
[Ps1Xml(Target = ViewControl.Table)]
25+
public string ClientId { get; set; }
26+
}
27+
}

src/ResourceManager/Network/Commands.Network/help/Add-AzApplicationGatewaySslCertificate.md

Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@ Adds an SSL certificate to an application gateway.
1515

1616
```
1717
Add-AzApplicationGatewaySslCertificate -ApplicationGateway <PSApplicationGateway> -Name <String>
18-
-CertificateFile <String> -Password <SecureString> [-DefaultProfile <IAzureContextContainer>]
19-
[<CommonParameters>]
18+
[-CertificateFile <String>] [-Password <SecureString>] [-KeyVaultSecretId <String>]
19+
[-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
2020
```
2121

2222
## DESCRIPTION
2323
The **Add-AzApplicationGatewaySslCertificate** cmdlet adds an SSL certificate to an application gateway.
2424

2525
## EXAMPLES
2626

27-
### Example 1: Add an SSL certificate to an application gateway.
27+
### Example 1: Add an SSL certificate using pfx to an application gateway.
2828
```
2929
PS C:\> $AppGW = Get-AzApplicationGateway -Name "ApplicationGateway01" -ResourceGroupName "ResourceGroup01"
3030
PS C:\> $password = ConvertTo-SecureString "P@ssw0rd" -AsPlainText -Force
@@ -33,6 +33,28 @@ PS C:\> $AppGW = Add-AzApplicationGatewaySslCertificate -ApplicationGateway $App
3333

3434
This command gets an application gateway named ApplicationGateway01 and then adds an SSL certificate named Cert01 to it.
3535

36+
### Example 2: Add an SSL certificate using KeyVault Secret (version-less secretId) to an application gateway.
37+
```
38+
PS C:\> $AppGW = Get-AzApplicationGateway -Name "ApplicationGateway01" -ResourceGroupName "ResourceGroup01"
39+
PS C:\> $secret = Get-AzKeyVaultSecret -VaultName "keyvault01" -Name "sslCert01"
40+
PS C:\> $secretId = $secret.Id.Replace($secret.Version, "") # https://<keyvaultname>.vault.azure.net/secrets/
41+
PS C:\> $AppGW = Add-AzApplicationGatewaySslCertificate -ApplicationGateway $AppGW -Name "Cert01" -KeyVaultSecretId $secretId
42+
```
43+
44+
Get the secret and reference it in the `Add-AzApplicationGatewaySslCertificate` to add it to the Application Gateway with name `Cert01`.
45+
Note: As version-less secretId is provided here, Application Gateway will sync the certificate in regular intervals with the KeyVault.
46+
47+
### Example 3: Add an SSL certificate using KeyVault Secret (versioned secretId) to an application gateway.
48+
```
49+
PS C:\> $AppGW = Get-AzApplicationGateway -Name "ApplicationGateway01" -ResourceGroupName "ResourceGroup01"
50+
PS C:\> $secret = Get-AzKeyVaultSecret -VaultName "keyvault01" -Name "sslCert01"
51+
PS C:\> $secretId = $secret.Id # https://<keyvaultname>.vault.azure.net/secrets/<hash>
52+
PS C:\> $AppGW = Add-AzApplicationGatewaySslCertificate -ApplicationGateway $AppGW -Name "Cert01" -KeyVaultSecretId $secretId
53+
```
54+
55+
Get the secret and reference it in the `Add-AzApplicationGatewaySslCertificate` to add it to the Application Gateway with name `Cert01`.
56+
Note: If it is required that Application Gateway syncs the certificate with the KeyVault, please provide the version-less secretId.
57+
3658
## PARAMETERS
3759

3860
### -ApplicationGateway
@@ -58,7 +80,7 @@ Type: System.String
5880
Parameter Sets: (All)
5981
Aliases:
6082

61-
Required: True
83+
Required: False
6284
Position: Named
6385
Default value: None
6486
Accept pipeline input: False
@@ -71,7 +93,22 @@ The credentials, account, tenant, and subscription used for communication with a
7193
```yaml
7294
Type: Microsoft.Azure.Commands.Common.Authentication.Abstractions.Core.IAzureContextContainer
7395
Parameter Sets: (All)
74-
Aliases: AzureRmContext, AzureCredential
96+
Aliases: AzContext, AzureRmContext, AzureCredential
97+
98+
Required: False
99+
Position: Named
100+
Default value: None
101+
Accept pipeline input: False
102+
Accept wildcard characters: False
103+
```
104+
105+
### -KeyVaultSecretId
106+
SecretId (uri) of the KeyVault Secret. Use this option when a specific version of secret needs to be used.
107+
108+
```yaml
109+
Type: System.String
110+
Parameter Sets: (All)
111+
Aliases:
75112

76113
Required: False
77114
Position: Named
@@ -103,7 +140,7 @@ Type: System.Security.SecureString
103140
Parameter Sets: (All)
104141
Aliases:
105142

106-
Required: True
143+
Required: False
107144
Position: Named
108145
Default value: None
109146
Accept pipeline input: False

src/ResourceManager/Network/Commands.Network/help/New-AzApplicationGateway.md

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ New-AzApplicationGateway -Name <String> -ResourceGroupName <String> -Location <S
3030
[-RedirectConfigurations <PSApplicationGatewayRedirectConfiguration[]>]
3131
[-WebApplicationFirewallConfiguration <PSApplicationGatewayWebApplicationFirewallConfiguration>]
3232
[-AutoscaleConfiguration <PSApplicationGatewayAutoscaleConfiguration>] [-EnableHttp2] [-EnableFIPS]
33-
[-Zone <String[]>] [-Tag <Hashtable>] [-Force] [-AsJob]
33+
[-Zone <String[]>] [-Tag <Hashtable>] [-UserAssignedIdentityId <String>]
34+
[-UserAssignedIdentity <PsUserAssignedIdentity>] [-Force] [-AsJob]
3435
[-CustomErrorConfiguration <PSApplicationGatewayCustomError[]>] [-DefaultProfile <IAzureContextContainer>]
3536
[-WhatIf] [-Confirm] [<CommonParameters>]
3637
```
@@ -191,7 +192,7 @@ The credentials, account, tenant, and subscription used for communication with a
191192
```yaml
192193
Type: Microsoft.Azure.Commands.Common.Authentication.Abstractions.Core.IAzureContextContainer
193194
Parameter Sets: (All)
194-
Aliases: AzureRmContext, AzureCredential
195+
Aliases: AzContext, AzureRmContext, AzureCredential
195196

196197
Required: False
197198
Position: Named
@@ -501,6 +502,36 @@ Accept pipeline input: True (ByPropertyName)
501502
Accept wildcard characters: False
502503
```
503504
505+
### -UserAssignedIdentity
506+
user assigned identity to be assigned to Application Gateway.
507+
508+
```yaml
509+
Type: Microsoft.Azure.Commands.ManagedServiceIdentity.Models.PsUserAssignedIdentity
510+
Parameter Sets: (All)
511+
Aliases:
512+
513+
Required: False
514+
Position: Named
515+
Default value: None
516+
Accept pipeline input: True (ByPropertyName)
517+
Accept wildcard characters: False
518+
```
519+
520+
### -UserAssignedIdentityId
521+
ResourceId of the user assigned identity to be assigned to Application Gateway.
522+
523+
```yaml
524+
Type: System.String
525+
Parameter Sets: (All)
526+
Aliases:
527+
528+
Required: False
529+
Position: Named
530+
Default value: None
531+
Accept pipeline input: True (ByPropertyName)
532+
Accept wildcard characters: False
533+
```
534+
504535
### -WebApplicationFirewallConfiguration
505536
Specifies a web application firewall (WAF) configuration. You can use the
506537
Get-AzApplicationGatewayWebApplicationFirewallConfiguration cmdlet to get a WAF.

0 commit comments

Comments
 (0)