diff --git a/src/Network/Network/ChangeLog.md b/src/Network/Network/ChangeLog.md index d9987e501bec..28335f3d8813 100644 --- a/src/Network/Network/ChangeLog.md +++ b/src/Network/Network/ChangeLog.md @@ -21,8 +21,6 @@ ## Upcoming Release * Bugfix in Remove peering and connection commandlet for ExpressrouteCircuit scenario - Remove-AzExpressRouteCircuitPeeringConfig and Remove-AzExpressRouteCircuitConnectionConfig -* Added multiple Authentication support for p2sVpnGateway - - Updated `New-AzVpnServerConfiguration` and `Update-AzVpnServerConfiguration` to allow multiple authentication parameters to be set. ## Version 4.3.0 * Updated below cmdlet - `New-AzLoadBalancerFrontendIpConfigCommand`, `Set-AzLoadBalancerFrontendIpConfigCommand`, `Add-AzLoadBalancerFrontendIpConfigCommand`: diff --git a/src/Network/Network/Cortex/VpnServerConfiguration/NewAzureRmVpnServerConfigurationCommand.cs b/src/Network/Network/Cortex/VpnServerConfiguration/NewAzureRmVpnServerConfigurationCommand.cs index 789b0cffc303..f4f0ec8def31 100644 --- a/src/Network/Network/Cortex/VpnServerConfiguration/NewAzureRmVpnServerConfigurationCommand.cs +++ b/src/Network/Network/Cortex/VpnServerConfiguration/NewAzureRmVpnServerConfigurationCommand.cs @@ -31,6 +31,7 @@ namespace Microsoft.Azure.Commands.Network [Cmdlet(VerbsCommon.New, ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "VpnServerConfiguration", + DefaultParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationName + CortexParameterSetNames.ByCertificateAuthentication, SupportsShouldProcess = true), OutputType(typeof(PSVpnServerConfiguration))] public class NewAzureRmVpnServerConfigurationCommand : VpnServerConfigurationBaseCmdlet @@ -75,47 +76,56 @@ public class NewAzureRmVpnServerConfigurationCommand : VpnServerConfigurationBas [Parameter( Mandatory = false, + ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationName + CortexParameterSetNames.ByCertificateAuthentication, HelpMessage = "A list of VpnClientRootCertificates to be added files' paths")] public string[] VpnClientRootCertificateFilesList { get; set; } [Parameter( Mandatory = false, + ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationName + CortexParameterSetNames.ByCertificateAuthentication, HelpMessage = "A list of VpnClientCertificates to be revoked files' paths")] public string[] VpnClientRevokedCertificateFilesList { get; set; } [Parameter( Mandatory = false, + ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationName + CortexParameterSetNames.ByRadiusAuthentication, HelpMessage = "P2S External Radius server address.")] public string RadiusServerAddress { get; set; } [Parameter( Mandatory = false, + ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationName + CortexParameterSetNames.ByRadiusAuthentication, HelpMessage = "P2S External Radius server secret.")] public SecureString RadiusServerSecret { get; set; } [Parameter( Mandatory = false, + ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationName + CortexParameterSetNames.ByRadiusAuthentication, HelpMessage = "P2S External multiple radius servers.")] public PSRadiusServer[] RadiusServerList { get; set; } [Parameter( Mandatory = false, + ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationName + CortexParameterSetNames.ByRadiusAuthentication, HelpMessage = "A list of RadiusClientRootCertificate files' paths")] public string[] RadiusServerRootCertificateFilesList { get; set; } [Parameter( Mandatory = false, + ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationName + CortexParameterSetNames.ByRadiusAuthentication, HelpMessage = "A list of RadiusClientRootCertificate files' paths")] public string[] RadiusClientRootCertificateFilesList { get; set; } [Parameter( Mandatory = false, + ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationName + CortexParameterSetNames.ByAadAuthentication, HelpMessage = "AAD tenant for P2S AAD authentication.")] [ValidateNotNullOrEmpty] public string AadTenant { get; set; } [Parameter( Mandatory = false, + ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationName + CortexParameterSetNames.ByAadAuthentication, HelpMessage = "AAD audience for P2S AAD authentication.")] [ValidateNotNullOrEmpty] public string AadAudience { get; set; } @@ -123,6 +133,7 @@ public class NewAzureRmVpnServerConfigurationCommand : VpnServerConfigurationBas [Parameter( Mandatory = false, + ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationName + CortexParameterSetNames.ByAadAuthentication, HelpMessage = "AAD issuer for P2S AAD authentication.")] [ValidateNotNullOrEmpty] public string AadIssuer { get; set; } diff --git a/src/Network/Network/Cortex/VpnServerConfiguration/UpdateAzureRmVpnServerConfigurationCommand.cs b/src/Network/Network/Cortex/VpnServerConfiguration/UpdateAzureRmVpnServerConfigurationCommand.cs index abb85ed42cd4..c5a99c7ec233 100644 --- a/src/Network/Network/Cortex/VpnServerConfiguration/UpdateAzureRmVpnServerConfigurationCommand.cs +++ b/src/Network/Network/Cortex/VpnServerConfiguration/UpdateAzureRmVpnServerConfigurationCommand.cs @@ -33,13 +33,21 @@ namespace Microsoft.Azure.Commands.Network [Cmdlet("Update", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "VpnServerConfiguration", - DefaultParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationName, + DefaultParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationName + CortexParameterSetNames.ByCertificateAuthentication, SupportsShouldProcess = true), OutputType(typeof(PSVpnServerConfiguration))] public class UpdateAzureRmVpnServerConfigurationCommand : VpnServerConfigurationBaseCmdlet { [Parameter( - ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationName, + ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationName + CortexParameterSetNames.ByCertificateAuthentication, + Mandatory = true, + HelpMessage = "The resource group name.")] + [Parameter( + ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationName + CortexParameterSetNames.ByRadiusAuthentication, + Mandatory = true, + HelpMessage = "The resource group name.")] + [Parameter( + ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationName + CortexParameterSetNames.ByAadAuthentication, Mandatory = true, HelpMessage = "The resource group name.")] [ResourceGroupCompleter] @@ -48,7 +56,15 @@ public class UpdateAzureRmVpnServerConfigurationCommand : VpnServerConfiguration [Alias("ResourceName", "VpnServerConfigurationName")] [Parameter( - ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationName, + ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationName + CortexParameterSetNames.ByCertificateAuthentication, + Mandatory = true, + HelpMessage = "The resource name.")] + [Parameter( + ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationName + CortexParameterSetNames.ByRadiusAuthentication, + Mandatory = true, + HelpMessage = "The resource name.")] + [Parameter( + ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationName + CortexParameterSetNames.ByAadAuthentication, Mandatory = true, HelpMessage = "The resource name.")] [ResourceNameCompleter("Microsoft.Network/vpnServerConfigurations", "ResourceGroupName")] @@ -57,7 +73,17 @@ public class UpdateAzureRmVpnServerConfigurationCommand : VpnServerConfiguration [Alias("VpnServerConfiguration")] [Parameter( - ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationObject, + ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationObject + CortexParameterSetNames.ByCertificateAuthentication, + Mandatory = true, + ValueFromPipeline = true, + HelpMessage = "The vpn server configuration object to be modified")] + [Parameter( + ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationObject + CortexParameterSetNames.ByRadiusAuthentication, + Mandatory = true, + ValueFromPipeline = true, + HelpMessage = "The vpn server configuration object to be modified")] + [Parameter( + ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationObject + CortexParameterSetNames.ByAadAuthentication, Mandatory = true, ValueFromPipeline = true, HelpMessage = "The vpn server configuration object to be modified")] @@ -66,7 +92,17 @@ public class UpdateAzureRmVpnServerConfigurationCommand : VpnServerConfiguration [Alias("VpnServerConfigurationId")] [Parameter( - ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationResourceId, + ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationResourceId + CortexParameterSetNames.ByCertificateAuthentication, + Mandatory = true, + ValueFromPipelineByPropertyName = true, + HelpMessage = "The Azure resource ID for the vpn server configuration.")] + [Parameter( + ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationResourceId + CortexParameterSetNames.ByRadiusAuthentication, + Mandatory = true, + ValueFromPipelineByPropertyName = true, + HelpMessage = "The Azure resource ID for the vpn server configuration.")] + [Parameter( + ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationResourceId + CortexParameterSetNames.ByAadAuthentication, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The Azure resource ID for the vpn server configuration.")] @@ -95,143 +131,143 @@ public class UpdateAzureRmVpnServerConfigurationCommand : VpnServerConfiguration [Parameter( Mandatory = false, - ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationName, + ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationName + CortexParameterSetNames.ByCertificateAuthentication, HelpMessage = "A list of VpnClientRootCertificates to be added files' paths")] [Parameter( Mandatory = false, - ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationObject, + ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationObject + CortexParameterSetNames.ByCertificateAuthentication, HelpMessage = "A list of VpnClientRootCertificates to be added files' paths")] [Parameter( Mandatory = false, - ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationResourceId, + ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationResourceId + CortexParameterSetNames.ByCertificateAuthentication, HelpMessage = "A list of VpnClientRootCertificates to be added files' paths")] public string[] VpnClientRootCertificateFilesList { get; set; } [Parameter( Mandatory = false, - ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationName, + ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationName + CortexParameterSetNames.ByCertificateAuthentication, HelpMessage = "A list of VpnClientCertificates to be revoked files' paths")] [Parameter( Mandatory = false, - ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationObject, + ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationObject + CortexParameterSetNames.ByCertificateAuthentication, HelpMessage = "A list of VpnClientCertificates to be revoked files' paths")] [Parameter( Mandatory = false, - ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationResourceId, + ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationResourceId + CortexParameterSetNames.ByCertificateAuthentication, HelpMessage = "A list of VpnClientCertificates to be revoked files' paths")] public string[] VpnClientRevokedCertificateFilesList { get; set; } [Parameter( Mandatory = false, - ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationName, + ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationName + CortexParameterSetNames.ByRadiusAuthentication, HelpMessage = "P2S External Radius server address.")] [Parameter( Mandatory = false, - ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationObject, + ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationObject + CortexParameterSetNames.ByRadiusAuthentication, HelpMessage = "P2S External Radius server address.")] [Parameter( Mandatory = false, - ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationResourceId, + ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationResourceId + CortexParameterSetNames.ByRadiusAuthentication, HelpMessage = "P2S External Radius server address.")] public string RadiusServerAddress { get; set; } [Parameter( Mandatory = false, - ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationName, + ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationName + CortexParameterSetNames.ByRadiusAuthentication, HelpMessage = "P2S External Radius server secret.")] [Parameter( Mandatory = false, - ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationObject, + ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationObject + CortexParameterSetNames.ByRadiusAuthentication, HelpMessage = "P2S External Radius server secret.")] [Parameter( Mandatory = false, - ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationResourceId, + ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationResourceId + CortexParameterSetNames.ByRadiusAuthentication, HelpMessage = "P2S External Radius server secret.")] public SecureString RadiusServerSecret { get; set; } [Parameter( Mandatory = false, - ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationName, + ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationName + CortexParameterSetNames.ByRadiusAuthentication, HelpMessage = "P2S External multiple radius servers.")] [Parameter( Mandatory = false, - ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationObject, + ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationObject + CortexParameterSetNames.ByRadiusAuthentication, HelpMessage = "P2S External multiple radius servers.")] [Parameter( Mandatory = false, - ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationResourceId, + ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationResourceId + CortexParameterSetNames.ByRadiusAuthentication, HelpMessage = "P2S External multiple radius servers.")] public PSRadiusServer[] RadiusServerList { get; set; } [Parameter( Mandatory = false, - ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationName, + ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationName + CortexParameterSetNames.ByRadiusAuthentication, HelpMessage = "A list of RadiusClientRootCertificate files' paths")] [Parameter( Mandatory = false, - ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationObject, + ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationObject + CortexParameterSetNames.ByRadiusAuthentication, HelpMessage = "A list of RadiusClientRootCertificate files' paths")] [Parameter( Mandatory = false, - ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationResourceId, + ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationResourceId + CortexParameterSetNames.ByRadiusAuthentication, HelpMessage = "A list of RadiusClientRootCertificate files' paths")] public string[] RadiusServerRootCertificateFilesList { get; set; } [Parameter( Mandatory = false, - ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationName, + ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationName + CortexParameterSetNames.ByRadiusAuthentication, HelpMessage = "A list of RadiusClientRootCertificate files' paths")] [Parameter( Mandatory = false, - ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationObject, + ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationObject + CortexParameterSetNames.ByRadiusAuthentication, HelpMessage = "A list of RadiusClientRootCertificate files' paths")] [Parameter( Mandatory = false, - ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationResourceId, + ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationResourceId + CortexParameterSetNames.ByRadiusAuthentication, HelpMessage = "A list of RadiusClientRootCertificate files' paths")] public string[] RadiusClientRootCertificateFilesList { get; set; } [Parameter( Mandatory = false, - ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationName, + ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationName + CortexParameterSetNames.ByAadAuthentication, HelpMessage = "AAD tenant for P2S AAD authentication.")] [Parameter( Mandatory = false, - ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationObject, + ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationObject + CortexParameterSetNames.ByAadAuthentication, HelpMessage = "AAD tenant for P2S AAD authentication.")] [Parameter( Mandatory = false, - ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationResourceId, + ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationResourceId + CortexParameterSetNames.ByAadAuthentication, HelpMessage = "AAD tenant for P2S AAD authentication.")] [ValidateNotNullOrEmpty] public string AadTenant { get; set; } [Parameter( Mandatory = false, - ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationName, + ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationName + CortexParameterSetNames.ByAadAuthentication, HelpMessage = "AAD audience for P2S AAD authentication.")] [Parameter( Mandatory = false, - ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationObject, + ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationObject + CortexParameterSetNames.ByAadAuthentication, HelpMessage = "AAD audience for P2S AAD authentication.")] [Parameter( Mandatory = false, - ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationResourceId, + ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationResourceId + CortexParameterSetNames.ByAadAuthentication, HelpMessage = "AAD audience for P2S AAD authentication.")] [ValidateNotNullOrEmpty] public string AadAudience { get; set; } [Parameter( Mandatory = false, - ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationName, + ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationName + CortexParameterSetNames.ByAadAuthentication, HelpMessage = "AAD issuer for P2S AAD authentication.")] [Parameter( Mandatory = false, - ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationObject, + ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationObject + CortexParameterSetNames.ByAadAuthentication, HelpMessage = "AAD issuer for P2S AAD authentication.")] [Parameter( Mandatory = false, - ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationResourceId, + ParameterSetName = CortexParameterSetNames.ByVpnServerConfigurationResourceId + CortexParameterSetNames.ByAadAuthentication, HelpMessage = "AAD issuer for P2S AAD authentication.")] [ValidateNotNullOrEmpty] public string AadIssuer { get; set; } @@ -337,14 +373,8 @@ public override void Execute() } } } - else - { - vpnServerConfigurationToUpdate.VpnClientRevokedCertificates = null; - vpnServerConfigurationToUpdate.VpnClientRootCertificates = null; - } - // VpnAuthenticationType = Radius related validations. - if (vpnServerConfigurationToUpdate.VpnAuthenticationTypes.Contains(MNM.VpnAuthenticationType.Radius)) + else if (vpnServerConfigurationToUpdate.VpnAuthenticationTypes.Contains(MNM.VpnAuthenticationType.Radius)) { if ((this.RadiusServerList != null && this.RadiusServerList.Count() > 0) && (this.RadiusServerAddress != null || this.RadiusServerSecret != null)) { @@ -410,17 +440,8 @@ public override void Execute() } } } - else - { - vpnServerConfigurationToUpdate.RadiusServerAddress = null; - vpnServerConfigurationToUpdate.RadiusServerSecret = null; - vpnServerConfigurationToUpdate.RadiusClientRootCertificates = null; - vpnServerConfigurationToUpdate.RadiusServerRootCertificates = null; - vpnServerConfigurationToUpdate.RadiusServers = null; - } - // VpnAuthenticationType = AAD related validations. - if (vpnServerConfigurationToUpdate.VpnAuthenticationTypes.Contains(MNM.VpnAuthenticationType.AAD)) + else if (vpnServerConfigurationToUpdate.VpnAuthenticationTypes.Contains(MNM.VpnAuthenticationType.AAD)) { if (vpnServerConfigurationToUpdate.AadAuthenticationParameters == null) { @@ -447,12 +468,6 @@ public override void Execute() vpnServerConfigurationToUpdate.AadAuthenticationParameters.AadIssuer = this.AadIssuer; } } - else - { - vpnServerConfigurationToUpdate.AadAuthenticationParameters.AadTenant = null; - vpnServerConfigurationToUpdate.AadAuthenticationParameters.AadIssuer = null; - vpnServerConfigurationToUpdate.AadAuthenticationParameters.AadAudience = null; - } ConfirmAction( Properties.Resources.SettingResourceMessage, diff --git a/src/Network/Network/Cortex/VpnServerConfiguration/VpnServerConfigurationBaseCmdlet.cs b/src/Network/Network/Cortex/VpnServerConfiguration/VpnServerConfigurationBaseCmdlet.cs index d4e8e44878f3..4885634e7382 100644 --- a/src/Network/Network/Cortex/VpnServerConfiguration/VpnServerConfigurationBaseCmdlet.cs +++ b/src/Network/Network/Cortex/VpnServerConfiguration/VpnServerConfigurationBaseCmdlet.cs @@ -171,7 +171,7 @@ public PSVpnServerConfiguration CreateVpnServerConfigurationObject( } } // VpnAuthenticationType = Radius related validations. - if (vpnAuthenticationType.Contains(MNM.VpnAuthenticationType.Radius)) + else if (vpnAuthenticationType.Contains(MNM.VpnAuthenticationType.Radius)) { if (radiusServerAddress != null) { @@ -224,7 +224,7 @@ public PSVpnServerConfiguration CreateVpnServerConfigurationObject( } } // VpnAuthenticationType = AAD related validations. - if (vpnAuthenticationType.Contains(MNM.VpnAuthenticationType.AAD)) + else if (vpnAuthenticationType.Contains(MNM.VpnAuthenticationType.AAD)) { if (aadTenant == null || aadAudience == null || aadIssuer == null) {