Skip to content

Commit eaa6d6d

Browse files
authored
Merge branch 'release-2018-12-18' into fix-mds
2 parents 6f76575 + 01997cb commit eaa6d6d

23 files changed

+280
-98
lines changed

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

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

15-
using AutoMapper;
1615
using Microsoft.Azure.Commands.Network.Models;
1716
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
1817
using Microsoft.Azure.Commands.ResourceManager.Common.Tags;
@@ -183,6 +182,15 @@ public class NewAzureApplicationGatewayCommand : ApplicationGatewayBaseCmdlet
183182
HelpMessage = "A hashtable which represents resource tags.")]
184183
public Hashtable Tag { get; set; }
185184

185+
[Parameter(
186+
Mandatory = false,
187+
ValueFromPipelineByPropertyName = true,
188+
HelpMessage = "ResourceId of the user assigned identity to be assigned to Application Gateway.")]
189+
[ValidateNotNullOrEmpty]
190+
[Alias("UserAssignedIdentity")]
191+
public string UserAssignedIdentityId { get; set; }
192+
193+
186194
[Parameter(
187195
Mandatory = false,
188196
HelpMessage = "Do not ask for confirmation if you want to overrite a resource")]
@@ -322,6 +330,18 @@ private PSApplicationGateway CreateApplicationGateway()
322330
applicationGateway.Zones = this.Zone?.ToList();
323331
}
324332

333+
if (this.UserAssignedIdentityId != null)
334+
{
335+
applicationGateway.Identity = new PSManagedServiceIdentity
336+
{
337+
Type = MNM.ResourceIdentityType.UserAssigned,
338+
UserAssignedIdentities = new Dictionary<string, PSManagedServiceIdentityUserAssignedIdentitiesValue>
339+
{
340+
{ this.UserAssignedIdentityId, new PSManagedServiceIdentityUserAssignedIdentitiesValue() }
341+
}
342+
};
343+
}
344+
325345
if (this.CustomErrorConfiguration != null)
326346
{
327347
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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,4 @@
6868
<ItemGroup>
6969
<Content Include="help\**\*" CopyToOutputDirectory="PreserveNewest" />
7070
</ItemGroup>
71-
</Project>
71+
</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: 42 additions & 5 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
@@ -80,6 +102,21 @@ Accept pipeline input: False
80102
Accept wildcard characters: False
81103
```
82104
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:
112+
113+
Required: False
114+
Position: Named
115+
Default value: None
116+
Accept pipeline input: False
117+
Accept wildcard characters: False
118+
```
119+
83120
### -Name
84121
Specifies the name of the SSL certificate that this cmdlet adds.
85122
@@ -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: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ 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>] [-Force] [-AsJob]
3434
[-CustomErrorConfiguration <PSApplicationGatewayCustomError[]>] [-DefaultProfile <IAzureContextContainer>]
3535
[-WhatIf] [-Confirm] [<CommonParameters>]
3636
```
@@ -501,6 +501,21 @@ Accept pipeline input: True (ByPropertyName)
501501
Accept wildcard characters: False
502502
```
503503
504+
### -UserAssignedIdentityId
505+
ResourceId of the user assigned identity to be assigned to Application Gateway.
506+
507+
```yaml
508+
Type: System.String
509+
Parameter Sets: (All)
510+
Aliases: UserAssignedIdentity
511+
512+
Required: False
513+
Position: Named
514+
Default value: None
515+
Accept pipeline input: True (ByPropertyName)
516+
Accept wildcard characters: False
517+
```
518+
504519
### -WebApplicationFirewallConfiguration
505520
Specifies a web application firewall (WAF) configuration. You can use the
506521
Get-AzApplicationGatewayWebApplicationFirewallConfiguration cmdlet to get a WAF.

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

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ Creates an SSL certificate for an Azure application gateway.
1414
## SYNTAX
1515

1616
```
17-
New-AzApplicationGatewaySslCertificate -Name <String> -CertificateFile <String> -Password <SecureString>
18-
[-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
17+
New-AzApplicationGatewaySslCertificate -Name <String> [-CertificateFile <String>] [-Password <SecureString>]
18+
[-KeyVaultSecretId <String>] [-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
1919
```
2020

2121
## DESCRIPTION
@@ -31,6 +31,26 @@ PS C:\> $cert = New-AzApplicationGatewaySslCertificate -Name "Cert01" -Certifica
3131

3232
This command creates a SSL certificate named Cert01 for the default application gateway and stores the result in the variable named $Cert.
3333

34+
### Example 2: Create an SSL certificate using KeyVault Secret (version-less secretId) and add to an application gateway.
35+
```
36+
PS C:\> $secret = Get-AzKeyVaultSecret -VaultName "keyvault01" -Name "sslCert01"
37+
PS C:\> $secretId = $secret.Id.Replace($secret.Version, "") # https://<keyvaultname>.vault.azure.net/secrets/
38+
PS C:\> $cert = New-AzApplicationGatewaySslCertificate -Name "Cert01" -KeyVaultSecretId $secretId
39+
```
40+
41+
Get the secret and create an SSL Certificate using `New-AzApplicationGatewaySslCertificate`.
42+
Note: As version-less secretId is provided here, Application Gateway will sync the certificate in regular intervals with the KeyVault.
43+
44+
### Example 3: Create an SSL certificate using KeyVault Secret and add to an Application Gateway.
45+
```
46+
PS C:\> $secret = Get-AzKeyVaultSecret -VaultName "keyvault01" -Name "sslCert01"
47+
PS C:\> $secretId = $secret.Id # https://<keyvaultname>.vault.azure.net/secrets/<hash>
48+
PS C:\> $cert = New-AzApplicationGatewaySslCertificate -Name "Cert01" -KeyVaultSecretId $secretId
49+
```
50+
51+
Get the secret and create an SSL Certificate using `New-AzApplicationGatewaySslCertificate`.
52+
Note: If it is required that Application Gateway syncs the certificate with the KeyVault, please provide the version-less secretId.
53+
3454
## PARAMETERS
3555

3656
### -CertificateFile
@@ -41,7 +61,7 @@ Type: System.String
4161
Parameter Sets: (All)
4262
Aliases:
4363

44-
Required: True
64+
Required: False
4565
Position: Named
4666
Default value: None
4767
Accept pipeline input: False
@@ -63,6 +83,21 @@ Accept pipeline input: False
6383
Accept wildcard characters: False
6484
```
6585
86+
### -KeyVaultSecretId
87+
SecretId (uri) of the KeyVault Secret. Use this option when a specific version of secret needs to be used.
88+
89+
```yaml
90+
Type: System.String
91+
Parameter Sets: (All)
92+
Aliases:
93+
94+
Required: False
95+
Position: Named
96+
Default value: None
97+
Accept pipeline input: False
98+
Accept wildcard characters: False
99+
```
100+
66101
### -Name
67102
Specifies the name of the SSL certificate that this cmdlet creates.
68103
@@ -86,7 +121,7 @@ Type: System.Security.SecureString
86121
Parameter Sets: (All)
87122
Aliases:
88123

89-
Required: True
124+
Required: False
90125
Position: Named
91126
Default value: None
92127
Accept pipeline input: False

0 commit comments

Comments
 (0)