public ApiManagementLongRunningOperation BeginCreateApiManagementService( string resourceGroupName, string serviceName, string location, string organization, string administratorEmail, PsApiManagementSku sku = PsApiManagementSku.Developer, int capacity = 1, IDictionary<string, string> tags = null) { var parameters = new ApiServiceCreateOrUpdateParameters { Location = location, Properties = new ApiServiceProperties { SkuProperties = new ApiServiceSkuProperties { Capacity = capacity, SkuType = MapSku(sku) }, PublisherEmail = administratorEmail, PublisherName = organization }, Tags = tags }; var longrunningResponse = Client.ResourceProvider.BeginCreatingOrUpdating(resourceGroupName, serviceName, parameters); AdjustRetryAfter(longrunningResponse, _client.LongRunningOperationInitialTimeout); return ApiManagementLongRunningOperation.CreateLongRunningOperation("New-AzureRmApiManagement", longrunningResponse); }
public PsApiManagementRegion AddRegion( string location, PsApiManagementSku sku = PsApiManagementSku.Developer, int capacity = 1, PsApiManagementVirtualNetwork virtualNetwork = null) { if (location == null) { throw new ArgumentNullException("location"); } if (location.Equals(Location) || AdditionalRegions.Any(r => location.Equals(r.Location))) { throw new ArgumentException(string.Format(Resources.AddRegionExistsMessage, location), "location"); } var newRegion = new PsApiManagementRegion { Location = location, Sku = sku, Capacity = capacity, VirtualNetwork = virtualNetwork }; AdditionalRegions.Add(newRegion); return(newRegion); }
public void UpdateRegion(string location, PsApiManagementSku sku, int capacity, PsApiManagementVirtualNetwork virtualNetwork) { if (location == null) { throw new ArgumentNullException("location"); } var regionToUpdate = AdditionalRegions.FirstOrDefault(r => location.Equals(r.Location)); if (regionToUpdate != null) { regionToUpdate.Sku = sku; regionToUpdate.Capacity = capacity; regionToUpdate.VirtualNetwork = virtualNetwork; } else if (location.Equals(Location)) { Sku = sku; Capacity = capacity; VirtualNetwork = virtualNetwork; } else { throw new ArgumentException(string.Format(Resources.UpdateRegionDoesNotExistsMessage, location), "location"); } }
public ApiManagementLongRunningOperation BeginCreateApiManagementService( string resourceGroupName, string serviceName, string location, string organization, string administratorEmail, PsApiManagementSku sku = PsApiManagementSku.Developer, int capacity = 1, IDictionary <string, string> tags = null) { var parameters = new ApiServiceCreateOrUpdateParameters { Location = location, Properties = new ApiServiceProperties { SkuProperties = new ApiServiceSkuProperties { Capacity = capacity, SkuType = MapSku(sku) }, PublisherEmail = administratorEmail, PublisherName = organization }, Tags = tags }; var longrunningResponse = Client.ResourceProvider.BeginCreatingOrUpdating(resourceGroupName, serviceName, parameters); AdjustRetryAfter(longrunningResponse, _client.LongRunningOperationInitialTimeout); return(ApiManagementLongRunningOperation.CreateLongRunningOperation("New-AzureRmApiManagement", longrunningResponse)); }
public ApiManagementLongRunningOperation BeginUpdateDeployments( string resourceGroupName, string serviceName, string location, PsApiManagementSku sku, int capacity, PsApiManagementVirtualNetwork vnetConfiguration, PsApiManagementVpnType vpnType, IList <PsApiManagementRegion> additionalRegions) { var parameters = new ApiServiceManageDeploymentsParameters(location, MapSku(sku)) { SkuUnitCount = capacity, VpnType = MapVirtualNetworkType(vpnType) }; if (vnetConfiguration != null) { parameters.VirtualNetworkConfiguration = new VirtualNetworkConfiguration { Location = vnetConfiguration.Location, SubnetResourceId = vnetConfiguration.SubnetResourceId }; } if (additionalRegions != null && additionalRegions.Any()) { parameters.AdditionalRegions = additionalRegions .Select(region => new AdditionalRegion { Location = region.Location, SkuType = MapSku(region.Sku), SkuUnitCount = region.Capacity, VirtualNetworkConfiguration = region.VirtualNetwork == null ? null : new VirtualNetworkConfiguration { Location = region.VirtualNetwork.Location, SubnetResourceId = region.VirtualNetwork.SubnetResourceId } }) .ToList(); } var longrunningResponse = Client.ResourceProvider.BeginManagingDeployments(resourceGroupName, serviceName, parameters); AdjustRetryAfter(longrunningResponse, _client.LongRunningOperationInitialTimeout); return(ApiManagementLongRunningOperation.CreateLongRunningOperation("Update-AzureRmApiManagementDeployment", longrunningResponse)); }
public static string MapSku(PsApiManagementSku sku) { switch (sku) { case PsApiManagementSku.Developer: return(SkuType.Developer); case PsApiManagementSku.Standard: return(SkuType.Standard); case PsApiManagementSku.Premium: return(SkuType.Premium); case PsApiManagementSku.Basic: return(SkuType.Basic); default: throw new ArgumentException("Unrecognized Sku"); } }
public static string MapSku(PsApiManagementSku sku) { switch (sku) { case PsApiManagementSku.Developer: return(SkuType.Developer); case PsApiManagementSku.Standard: return(SkuType.Standard); case PsApiManagementSku.Premium: return(SkuType.Premium); case PsApiManagementSku.Basic: return(SkuType.Basic); case PsApiManagementSku.Consumption: return(SkuType.Consumption); case PsApiManagementSku.Isolated: return(SkuType.Isolated); default: throw new ArgumentException($"Unrecognized Sku '{sku.ToString()}'"); } }
public void UpdateRegion( string location, PsApiManagementSku sku, int capacity, PsApiManagementVirtualNetwork virtualNetwork, string[] zone, bool?disableGateway, string publicIpAddressId) { if (location == null) { throw new ArgumentNullException("location"); } var regionToUpdate = AdditionalRegions.FirstOrDefault(r => location.Trim().Equals(r.Location, StringComparison.OrdinalIgnoreCase)); if (regionToUpdate != null) { // if this is additional region regionToUpdate.Sku = sku; regionToUpdate.Capacity = capacity; regionToUpdate.VirtualNetwork = virtualNetwork; regionToUpdate.Zone = zone; regionToUpdate.DisableGateway = disableGateway; regionToUpdate.PublicIpAddressId = publicIpAddressId; } else if (location.Equals(Location)) { // if this is master region Sku = sku; Capacity = capacity; VirtualNetwork = virtualNetwork; Zone = zone; DisableGateway = disableGateway; PublicIpAddressId = publicIpAddressId; } else { throw new ArgumentException(string.Format(Resources.UpdateRegionDoesNotExistsMessage, location), "location"); } }
public PsApiManagementRegion AddRegion( string location, PsApiManagementSku sku = PsApiManagementSku.Developer, int capacity = 1, PsApiManagementVirtualNetwork virtualNetwork = null) { if (location == null) { throw new ArgumentNullException("location"); } if (location.Equals(Location) || AdditionalRegions.Any(r => location.Equals(r.Location))) { throw new ArgumentException(string.Format(Resources.AddRegionExistsMessage, location), "location"); } var newRegion = new PsApiManagementRegion { Location = location, Sku = sku, Capacity = capacity, VirtualNetwork = virtualNetwork }; AdditionalRegions.Add(newRegion); return newRegion; }
public ApiManagementLongRunningOperation BeginCreateApiManagementService( string resourceGroupName, string serviceName, string location, string organization, string administratorEmail, PsApiManagementSku sku = PsApiManagementSku.Developer, int capacity = 1, PsApiManagementVpnType vpnType = PsApiManagementVpnType.None, IDictionary <string, string> tags = null, PsApiManagementVirtualNetwork virtualNetwork = null, PsApiManagementRegion[] additionalRegions = null) { var parameters = new ApiServiceCreateOrUpdateParameters { Location = location, Properties = new ApiServiceProperties { PublisherEmail = administratorEmail, PublisherName = organization, VpnType = MapVirtualNetworkType(vpnType) }, SkuProperties = new ApiServiceSkuProperties { Capacity = capacity, SkuType = MapSku(sku) }, Tags = tags }; if (virtualNetwork != null) { parameters.Properties.VirtualNetworkConfiguration = new VirtualNetworkConfiguration { Location = virtualNetwork.Location, SubnetResourceId = virtualNetwork.SubnetResourceId }; } if (additionalRegions != null && additionalRegions.Any()) { parameters.Properties.AdditionalRegions = additionalRegions .Select(region => new AdditionalRegion { Location = region.Location, SkuType = MapSku(region.Sku), SkuUnitCount = region.Capacity, VirtualNetworkConfiguration = region.VirtualNetwork == null ? null : new VirtualNetworkConfiguration { Location = region.VirtualNetwork.Location, SubnetResourceId = region.VirtualNetwork.SubnetResourceId } }) .ToList(); } var longrunningResponse = Client.ResourceProvider.BeginCreatingOrUpdating(resourceGroupName, serviceName, parameters); AdjustRetryAfter(longrunningResponse, _client.LongRunningOperationInitialTimeout); return(ApiManagementLongRunningOperation.CreateLongRunningOperation("New-AzureRmApiManagement", longrunningResponse)); }
private static SkuType MapSku(PsApiManagementSku sku) { return(Mapper.Map <PsApiManagementSku, SkuType>(sku)); }
private static SkuType MapSku(PsApiManagementSku sku) { return Mapper.Map<PsApiManagementSku, SkuType>(sku); }
public PsApiManagement CreateApiManagementService( string resourceGroupName, string serviceName, string location, string organization, string administratorEmail, Dictionary <string, string> tags, bool enableClientCertificate, PsApiManagementSku sku = PsApiManagementSku.Developer, int?capacity = null, PsApiManagementVpnType vpnType = PsApiManagementVpnType.None, PsApiManagementVirtualNetwork virtualNetwork = null, PsApiManagementRegion[] additionalRegions = null, PsApiManagementCustomHostNameConfiguration[] customHostnameConfigurations = null, PsApiManagementSystemCertificate[] systemCertificates = null, PsApiManagementSslSetting sslSettings = null, bool createSystemResourceIdentity = false, string[] userAssignedIdentity = null, string[] zone = null, bool?disableGateway = null, string minimalControlPlaneApiVersion = null, string publicNetworkAccess = null, string publicIpAddressId = null) { string skuType = Mappers.MapSku(sku); if (capacity == null) { capacity = (sku == PsApiManagementSku.Consumption ? 0 : 1); } var skuProperties = new ApiManagementServiceSkuProperties(skuType, capacity.Value); var parameters = new ApiManagementServiceResource { Location = location, PublisherEmail = administratorEmail, PublisherName = organization, VirtualNetworkType = Mappers.MapVirtualNetworkType(vpnType), Sku = skuProperties, Tags = tags }; if (virtualNetwork != null) { parameters.VirtualNetworkConfiguration = new VirtualNetworkConfiguration { SubnetResourceId = virtualNetwork.SubnetResourceId }; } if (additionalRegions != null && additionalRegions.Any()) { parameters.AdditionalLocations = additionalRegions .Select(region => region.GetAdditionalLocation()) .ToList(); } if (customHostnameConfigurations != null) { parameters.HostnameConfigurations = BuildHostNameConfiguration(customHostnameConfigurations); } if (systemCertificates != null) { parameters.Certificates = new List <CertificateConfiguration>(); foreach (var systemCertificate in systemCertificates) { var certificateConfig = systemCertificate.GetCertificateConfiguration(); parameters.Certificates.Add(certificateConfig); } } if (sslSettings != null) { parameters.CustomProperties = Mappers.MapPsApiManagementSslSetting(sslSettings); } if (enableClientCertificate) { parameters.EnableClientCertificate = enableClientCertificate; } if (zone != null) { parameters.Zones = zone; } if (disableGateway != null && disableGateway.HasValue) { parameters.DisableGateway = disableGateway.Value; } if (!string.IsNullOrWhiteSpace(minimalControlPlaneApiVersion)) { parameters.ApiVersionConstraint = new ApiVersionConstraint() { MinApiVersion = minimalControlPlaneApiVersion }; } if (publicIpAddressId != null) { parameters.PublicIpAddressId = publicIpAddressId; } if (publicNetworkAccess != null) { parameters.PublicNetworkAccess = publicNetworkAccess; } parameters.Identity = Mappers.MapAssignedIdentity(createSystemResourceIdentity, userAssignedIdentity); var apiManagementResource = Client.ApiManagementService.CreateOrUpdate(resourceGroupName, serviceName, parameters); return(new PsApiManagement(apiManagementResource)); }
public PsApiManagement UpdateDeployment( string resourceGroupName, string serviceName, string location, PsApiManagementSku sku, int capacity, PsApiManagementVirtualNetwork vnetConfiguration, PsApiManagementVpnType vpnType, IList <PsApiManagementRegion> additionalRegions, PsApiManagement apiManagement) { ApiManagementServiceResource apiManagementParameters; if (apiManagement != null) { apiManagementParameters = Mappers.MapPsApiManagement(apiManagement); } else { apiManagementParameters = Client.ApiManagementService.Get(resourceGroupName, serviceName); apiManagementParameters.Sku = new ApiManagementServiceSkuProperties() { Name = Mappers.MapSku(sku), Capacity = capacity }; if (vnetConfiguration != null) { apiManagementParameters.VirtualNetworkConfiguration = new VirtualNetworkConfiguration() { SubnetResourceId = vnetConfiguration.SubnetResourceId }; } apiManagementParameters.VirtualNetworkType = Mappers.MapVirtualNetworkType(vpnType); if (additionalRegions != null && additionalRegions.Any()) { apiManagementParameters.AdditionalLocations = new List <AdditionalLocation>(); foreach (var additionalRegion in additionalRegions) { apiManagementParameters.AdditionalLocations.Add(new AdditionalLocation() { Location = additionalRegion.Location, Sku = new ApiManagementServiceSkuProperties() { Name = Mappers.MapSku(additionalRegion.Sku), Capacity = additionalRegion.Capacity }, VirtualNetworkConfiguration = additionalRegion.VirtualNetwork == null ? null : new VirtualNetworkConfiguration() { SubnetResourceId = additionalRegion.VirtualNetwork.SubnetResourceId } }); } } } var apiManagementService = Client.ApiManagementService.CreateOrUpdate(resourceGroupName, serviceName, apiManagementParameters); return(new PsApiManagement(apiManagementService)); }
public ApiManagementLongRunningOperation BeginUpdateDeployments( string resourceGroupName, string serviceName, string location, PsApiManagementSku sku, int capacity, PsApiManagementVirtualNetwork vnetConfiguration, IList<PsApiManagementRegion> additionalRegions) { var parameters = new ApiServiceManageDeploymentsParameters(location, MapSku(sku)) { SkuUnitCount = capacity }; if (vnetConfiguration != null) { parameters.VirtualNetworkConfiguration = new VirtualNetworkConfiguration { Location = vnetConfiguration.Location, SubnetName = vnetConfiguration.SubnetName, VnetId = vnetConfiguration.VnetId }; } if (additionalRegions != null && additionalRegions.Any()) { parameters.AdditionalRegions = additionalRegions .Select(region => new AdditionalRegion { Location = region.Location, SkuType = MapSku(region.Sku), SkuUnitCount = region.Capacity, VirtualNetworkConfiguration = region.VirtualNetwork == null ? null : new VirtualNetworkConfiguration { Location = region.VirtualNetwork.Location, SubnetName = region.VirtualNetwork.SubnetName, VnetId = region.VirtualNetwork.VnetId } }) .ToList(); } var longrunningResponse = Client.ResourceProvider.BeginManagingDeployments(resourceGroupName, serviceName, parameters); AdjustRetryAfter(longrunningResponse, _client.LongRunningOperationInitialTimeout); return ApiManagementLongRunningOperation.CreateLongRunningOperation("Update-AzureRmApiManagementDeployment", longrunningResponse); }
public PsApiManagement CreateApiManagementService( string resourceGroupName, string serviceName, string location, string organization, string administratorEmail, Dictionary <string, string> tags, bool enableClientCertificate, PsApiManagementSku sku = PsApiManagementSku.Developer, int?capacity = null, PsApiManagementVpnType vpnType = PsApiManagementVpnType.None, PsApiManagementVirtualNetwork virtualNetwork = null, PsApiManagementRegion[] additionalRegions = null, PsApiManagementCustomHostNameConfiguration[] customHostnameConfigurations = null, PsApiManagementSystemCertificate[] systemCertificates = null, PsApiManagementSslSetting sslSettings = null, bool createSystemResourceIdentity = false, string[] userAssignedIdentity = null) { string skuType = Mappers.MapSku(sku); if (capacity == null) { capacity = (sku == PsApiManagementSku.Consumption ? 0 : 1); } var skuProperties = new ApiManagementServiceSkuProperties(skuType, capacity.Value); var parameters = new ApiManagementServiceResource { Location = location, PublisherEmail = administratorEmail, PublisherName = organization, VirtualNetworkType = Mappers.MapVirtualNetworkType(vpnType), Sku = skuProperties, Tags = tags }; if (virtualNetwork != null) { parameters.VirtualNetworkConfiguration = new VirtualNetworkConfiguration { SubnetResourceId = virtualNetwork.SubnetResourceId }; } if (additionalRegions != null && additionalRegions.Any()) { parameters.AdditionalLocations = additionalRegions .Select(region => new AdditionalLocation { Location = region.Location, Sku = new ApiManagementServiceSkuProperties() { Name = Mappers.MapSku(region.Sku), Capacity = region.Capacity }, VirtualNetworkConfiguration = region.VirtualNetwork == null ? null : new VirtualNetworkConfiguration { SubnetResourceId = region.VirtualNetwork.SubnetResourceId } }) .ToList(); } if (customHostnameConfigurations != null) { parameters.HostnameConfigurations = BuildHostNameConfiguration(customHostnameConfigurations); } if (systemCertificates != null) { parameters.Certificates = new List <CertificateConfiguration>(); foreach (var systemCertificate in systemCertificates) { var certificateConfig = systemCertificate.GetCertificateConfiguration(); parameters.Certificates.Add(certificateConfig); } } if (sslSettings != null) { parameters.CustomProperties = Mappers.MapPsApiManagementSslSetting(sslSettings); } if (enableClientCertificate) { parameters.EnableClientCertificate = enableClientCertificate; } parameters.Identity = Mappers.MapAssignedIdentity(createSystemResourceIdentity, userAssignedIdentity); var apiManagementResource = Client.ApiManagementService.CreateOrUpdate(resourceGroupName, serviceName, parameters); return(new PsApiManagement(apiManagementResource)); }
public ApiManagementLongRunningOperation BeginCreateApiManagementService( string resourceGroupName, string serviceName, string location, string organization, string administratorEmail, PsApiManagementSku sku = PsApiManagementSku.Developer, int capacity = 1, PsApiManagementVpnType vpnType = PsApiManagementVpnType.None, IDictionary<string, string> tags = null, PsApiManagementVirtualNetwork virtualNetwork = null, PsApiManagementRegion[] additionalRegions = null) { var parameters = new ApiServiceCreateOrUpdateParameters { Location = location, Properties = new ApiServiceProperties { PublisherEmail = administratorEmail, PublisherName = organization, VpnType = MapVirtualNetworkType(vpnType) }, SkuProperties = new ApiServiceSkuProperties { Capacity = capacity, SkuType = MapSku(sku) }, Tags = tags }; if (virtualNetwork != null) { parameters.Properties.VirtualNetworkConfiguration = new VirtualNetworkConfiguration { Location = virtualNetwork.Location, SubnetResourceId = virtualNetwork.SubnetResourceId }; } if (additionalRegions != null && additionalRegions.Any()) { parameters.Properties.AdditionalRegions = additionalRegions .Select(region => new AdditionalRegion { Location = region.Location, SkuType = MapSku(region.Sku), SkuUnitCount = region.Capacity, VirtualNetworkConfiguration = region.VirtualNetwork == null ? null : new VirtualNetworkConfiguration { Location = region.VirtualNetwork.Location, SubnetResourceId = region.VirtualNetwork.SubnetResourceId } }) .ToList(); } var longrunningResponse = Client.ResourceProvider.BeginCreatingOrUpdating(resourceGroupName, serviceName, parameters); AdjustRetryAfter(longrunningResponse, _client.LongRunningOperationInitialTimeout); return ApiManagementLongRunningOperation.CreateLongRunningOperation("New-AzureRmApiManagement", longrunningResponse); }