public override void ExecuteCmdlet() { base.ExecuteCmdlet(); if (!this.IsApplicationGatewayPresent(this.ApplicationGateway.ResourceGroupName, this.ApplicationGateway.Name)) { throw new ArgumentException(Microsoft.Azure.Commands.Network.Properties.Resources.ResourceNotFound); } // Normalize the IDs ApplicationGatewayChildResourceHelper.NormalizeChildIds(ApplicationGateway, ApplicationGateway.ResourceGroupName, ApplicationGateway.Name); // Map to the sdk object var appGwModel = NetworkResourceManagerProfile.Mapper.Map <MNM.ApplicationGateway>(this.ApplicationGateway); appGwModel.Tags = TagsConversionHelper.CreateTagDictionary(this.ApplicationGateway.Tag, validate: true); // Execute the Create VirtualNetwork call this.ApplicationGatewayClient.CreateOrUpdate(this.ApplicationGateway.ResourceGroupName, this.ApplicationGateway.Name, appGwModel); var getApplicationGateway = this.GetApplicationGateway(this.ApplicationGateway.ResourceGroupName, this.ApplicationGateway.Name); WriteObject(getApplicationGateway); }
private PSApplicationGateway CreateApplicationGateway() { var applicationGateway = new PSApplicationGateway(); applicationGateway.Name = this.Name; applicationGateway.ResourceGroupName = this.ResourceGroupName; applicationGateway.Location = this.Location; applicationGateway.Sku = this.Sku; if (this.SslPolicy != null) { applicationGateway.SslPolicy = new PSApplicationGatewaySslPolicy(); applicationGateway.SslPolicy = this.SslPolicy; } if (this.GatewayIPConfigurations != null) { applicationGateway.GatewayIPConfigurations = this.GatewayIPConfigurations?.ToList(); } if (this.SslCertificates != null) { applicationGateway.SslCertificates = this.SslCertificates?.ToList(); } if (this.AuthenticationCertificates != null) { applicationGateway.AuthenticationCertificates = this.AuthenticationCertificates?.ToList(); } if (this.TrustedRootCertificate != null) { applicationGateway.TrustedRootCertificates = this.TrustedRootCertificate?.ToList(); } if (this.FrontendIPConfigurations != null) { applicationGateway.FrontendIPConfigurations = this.FrontendIPConfigurations?.ToList(); } if (this.FrontendPorts != null) { applicationGateway.FrontendPorts = this.FrontendPorts?.ToList(); } if (this.Probes != null) { applicationGateway.Probes = this.Probes?.ToList(); } if (this.BackendAddressPools != null) { applicationGateway.BackendAddressPools = this.BackendAddressPools?.ToList(); } if (this.BackendHttpSettingsCollection != null) { applicationGateway.BackendHttpSettingsCollection = this.BackendHttpSettingsCollection?.ToList(); } if (this.HttpListeners != null) { applicationGateway.HttpListeners = this.HttpListeners?.ToList(); } if (this.UrlPathMaps != null) { applicationGateway.UrlPathMaps = this.UrlPathMaps?.ToList(); } if (this.RequestRoutingRules != null) { applicationGateway.RequestRoutingRules = this.RequestRoutingRules?.ToList(); } if (this.RewriteRuleSet != null) { applicationGateway.RewriteRuleSets = this.RewriteRuleSet?.ToList(); } if (this.RedirectConfigurations != null) { applicationGateway.RedirectConfigurations = this.RedirectConfigurations?.ToList(); } if (this.WebApplicationFirewallConfiguration != null) { applicationGateway.WebApplicationFirewallConfiguration = this.WebApplicationFirewallConfiguration; } if (!string.IsNullOrEmpty(this.FirewallPolicyId)) { applicationGateway.FirewallPolicy = new PSResourceId(); applicationGateway.FirewallPolicy.Id = this.FirewallPolicyId; } if (this.AutoscaleConfiguration != null) { applicationGateway.AutoscaleConfiguration = this.AutoscaleConfiguration; } if (this.EnableHttp2.IsPresent) { applicationGateway.EnableHttp2 = true; } if (this.EnableFIPS.IsPresent) { applicationGateway.EnableFips = true; } if (this.Zone != null) { applicationGateway.Zones = this.Zone?.ToList(); } if (this.UserAssignedIdentityId != null) { applicationGateway.Identity = new PSManagedServiceIdentity { Type = MNM.ResourceIdentityType.UserAssigned, UserAssignedIdentities = new Dictionary <string, PSManagedServiceIdentityUserAssignedIdentitiesValue> { { this.UserAssignedIdentityId, new PSManagedServiceIdentityUserAssignedIdentitiesValue() } } }; } else if (this.Identity != null) { applicationGateway.Identity = this.Identity; } if (this.CustomErrorConfiguration != null) { applicationGateway.CustomErrorConfigurations = this.CustomErrorConfiguration?.ToList(); } // Normalize the IDs ApplicationGatewayChildResourceHelper.NormalizeChildIds(applicationGateway, this.ResourceGroupName, this.Name); // Map to the sdk object var appGwModel = NetworkResourceManagerProfile.Mapper.Map <MNM.ApplicationGateway>(applicationGateway); appGwModel.Tags = TagsConversionHelper.CreateTagDictionary(this.Tag, validate: true); // Execute the Create ApplicationGateway call this.ApplicationGatewayClient.CreateOrUpdate(this.ResourceGroupName, this.Name, appGwModel); var getApplicationGateway = this.GetApplicationGateway(this.ResourceGroupName, this.Name); return(getApplicationGateway); }