private static String toConnectionString(EventHubNamespace eventHubNamespace) { return eventHubNamespace.listAuthorizationRules().stream().findFirst().map(AuthorizationRule::getKeys) .map(EventHubAuthorizationKey::primaryConnectionString).orElseThrow( () -> new EventHubRuntimeException( String.format("Failed to fetch connection string of namespace '%s'", eventHubNamespace.name()), null)); }
private static String toConnectionString(EventHubNamespace eventHubNamespace) { return eventHubNamespace.listAuthorizationRules().stream().findFirst().map(AuthorizationRule::getKeys) .map(EventHubAuthorizationKey::primaryConnectionString).orElseThrow( () -> new EventHubRuntimeException( String.format("Failed to fetch connection string of namespace '%s'", eventHubNamespace.name()), null)); }
@Override public EventHubConsumerGroup internalGet(Tuple<EventHub, String> eventHubAndGroup) { return eventHubAndGroup.getFirst().listConsumerGroups().stream() .filter(c -> c.name().equals(eventHubAndGroup.getSecond())).findAny().orElse(null); }
private static String buildConnectionString(ResourceManager<ServiceBusNamespace, String> serviceBusNamespaceManager, String namespace) { return serviceBusNamespaceManager.getOrCreate(namespace).authorizationRules().list().stream().findFirst() .map(com.microsoft.azure.management.servicebus.AuthorizationRule::getKeys) .map(AuthorizationKeys::primaryConnectionString) .map(s -> new ConnectionStringBuilder(s, namespace).toString()).orElseThrow( () -> new RuntimeException( String.format("Service bus namespace '%s' key is empty", namespace), null)); }
private static String buildConnectionString(ResourceManager<ServiceBusNamespace, String> serviceBusNamespaceManager, String namespace) { return serviceBusNamespaceManager.getOrCreate(namespace).authorizationRules().list().stream().findFirst() .map(com.microsoft.azure.management.servicebus.AuthorizationRule::getKeys) .map(AuthorizationKeys::primaryConnectionString) .map(s -> new ConnectionStringBuilder(s, namespace).toString()).orElseThrow( () -> new RuntimeException( String.format("Service bus namespace '%s' key is empty", namespace), null)); }
@Primary @Bean public KafkaProperties kafkaProperties(ResourceManagerProvider resourceManagerProvider, AzureEventHubProperties eventHubProperties) { KafkaProperties kafkaProperties = new KafkaProperties(); EventHubNamespace namespace = resourceManagerProvider.getEventHubNamespaceManager().getOrCreate(eventHubProperties.getNamespace()); String connectionString = namespace.listAuthorizationRules().stream().findFirst().map(AuthorizationRule::getKeys) .map(EventHubAuthorizationKey::primaryConnectionString).orElseThrow(() -> new RuntimeException( String.format("Failed to fetch connection string of namespace '%s'", namespace), null)); String endpoint = namespace.serviceBusEndpoint(); String endpointHost = endpoint.substring("https://".length(), endpoint.lastIndexOf(':')); kafkaProperties.setBootstrapServers(Arrays.asList(endpointHost + ":" + PORT)); kafkaProperties.getProperties().put(SECURITY_PROTOCOL, SASL_SSL); kafkaProperties.getProperties().put(SASL_MECHANISM, SASL_MECHANISM_PLAIN); kafkaProperties.getProperties().put(SASL_JAAS_CONFIG, String.format(SASL_CONFIG_VALUE, connectionString)); return kafkaProperties; } }
/** * List all web apps by subscription id. */ @NotNull public List<ResourceEx<WebApp>> listWebApps(final String subscriptionId, final boolean force) { if (!force && subscriptionIdToWebApps.get(subscriptionId) != null) { return subscriptionIdToWebApps.get(subscriptionId); } List<ResourceEx<WebApp>> webApps = new ArrayList<>(); try { final Azure azure = AuthMethodManager.getInstance().getAzureClient(subscriptionId); webApps = azure.webApps().list() .stream() .map(app -> new ResourceEx<WebApp>(app, subscriptionId)) .collect(Collectors.toList()); subscriptionIdToWebApps.put(subscriptionId, webApps); } catch (IOException e) { e.printStackTrace(); } return webApps; }
@Primary @Bean public KafkaProperties kafkaProperties(ResourceManagerProvider resourceManagerProvider, AzureEventHubProperties eventHubProperties) { KafkaProperties kafkaProperties = new KafkaProperties(); EventHubNamespace namespace = resourceManagerProvider.getEventHubNamespaceManager().getOrCreate(eventHubProperties.getNamespace()); String connectionString = namespace.listAuthorizationRules().stream().findFirst().map(AuthorizationRule::getKeys) .map(EventHubAuthorizationKey::primaryConnectionString).orElseThrow(() -> new RuntimeException( String.format("Failed to fetch connection string of namespace '%s'", namespace), null)); String endpoint = namespace.serviceBusEndpoint(); String endpointHost = endpoint.substring("https://".length(), endpoint.lastIndexOf(':')); kafkaProperties.setBootstrapServers(Arrays.asList(endpointHost + ":" + PORT)); kafkaProperties.getProperties().put(SECURITY_PROTOCOL, SASL_SSL); kafkaProperties.getProperties().put(SASL_MECHANISM, SASL_MECHANISM_PLAIN); kafkaProperties.getProperties().put(SASL_JAAS_CONFIG, String.format(SASL_CONFIG_VALUE, connectionString)); return kafkaProperties; } }
List<String> locations = subscription.listLocations().stream().sorted(Comparator.comparing(Location::displayName)) .map(o -> o.name().toLowerCase()).collect(Collectors.toList()); dockerSubscription.locations = locations;
/** * API to create a new Deployment Slot by setting model. */ public DeploymentSlot createDeploymentSlot(@NotNull WebAppSettingModel model) throws Exception { final WebApp app = getWebAppById(model.getSubscriptionId(), model.getWebAppId()); final String name = model.getNewSlotName(); final String configurationSource = model.getNewSlotConfigurationSource(); final DeploymentSlot.DefinitionStages.Blank definedSlot = app.deploymentSlots().define(name); if (configurationSource.equals(app.name())) { return definedSlot.withConfigurationFromParent().create(); } final DeploymentSlot configurationSourceSlot = app.deploymentSlots() .list() .stream() .filter(s -> configurationSource.equals(s.name())) .findAny() .orElse(null); if (configurationSourceSlot != null) { return definedSlot.withConfigurationFromDeploymentSlot(configurationSourceSlot).create(); } else { return definedSlot.withBrandNewConfiguration().create(); } }