private void initializeFunctionService() { if (functionService == null) { HttpUrl defaultHostName = HttpUrl.parse(defaultHostName()); if (defaultHostName == null) { defaultHostName = new HttpUrl.Builder().host(defaultHostName()).scheme("http").build(); } functionService = manager().restClient().newBuilder() .withBaseUrl(defaultHostName.toString()) .withCredentials(new FunctionCredentials(this)) .withLogLevel(LogLevel.BODY_AND_HEADERS) .build() .retrofit().create(FunctionService.class); } }
@Bean @ConditionalOnMissingBean public Azure azure(AzureProperties azureProperties) throws IOException { CredentialsProvider credentialsProvider = new DefaultCredentialsProvider(azureProperties); ApplicationTokenCredentials credentials = credentialsProvider.getCredentials(); TelemetryCollector.getInstance().setSubscription(credentials.defaultSubscriptionId()); RestClient restClient = new RestClient.Builder() .withBaseUrl(credentials.environment(), AzureEnvironment.Endpoint.RESOURCE_MANAGER) .withCredentials(credentials).withSerializerAdapter(new AzureJacksonAdapter()) .withResponseBuilderFactory(new AzureResponseBuilder.Factory()) .withInterceptor(new ProviderRegistrationInterceptor(credentials)) .withInterceptor(new ResourceManagerThrottlingInterceptor()).withUserAgent(SPRING_CLOUD_USER_AGENT) .build(); return Azure.authenticate(restClient, credentials.domain()).withDefaultSubscription(); }
@Bean @ConditionalOnMissingBean public Azure azure(AzureProperties azureProperties) throws IOException { CredentialsProvider credentialsProvider = new DefaultCredentialsProvider(azureProperties); ApplicationTokenCredentials credentials = credentialsProvider.getCredentials(); TelemetryCollector.getInstance().setSubscription(credentials.defaultSubscriptionId()); RestClient restClient = new RestClient.Builder() .withBaseUrl(credentials.environment(), AzureEnvironment.Endpoint.RESOURCE_MANAGER) .withCredentials(credentials).withSerializerAdapter(new AzureJacksonAdapter()) .withResponseBuilderFactory(new AzureResponseBuilder.Factory()) .withInterceptor(new ProviderRegistrationInterceptor(credentials)) .withInterceptor(new ResourceManagerThrottlingInterceptor()).withUserAgent(SPRING_CLOUD_USER_AGENT) .build(); return Azure.authenticate(restClient, credentials.domain()).withDefaultSubscription(); }
/** * Creates an instance of PolicyManager that exposes Authorization resource management API entry points. * * @param credentials the credentials to use * @param subscriptionId the subscription UUID * @return the PolicyManager */ public static PolicyManager authenticate(AzureTokenCredentials credentials, String subscriptionId) { return new PolicyManager(new RestClient.Builder() .withBaseUrl(credentials.environment(), AzureEnvironment.Endpoint.RESOURCE_MANAGER) .withCredentials(credentials) .withSerializerAdapter(new AzureJacksonAdapter()) .withResponseBuilderFactory(new AzureResponseBuilder.Factory()) .build(), subscriptionId); } /**
/** * Creates an instance of Manager that exposes resource management API entry points. * * @param credentials the credentials to use * @return the Manager */ public static Manager authenticate(AzureTokenCredentials credentials) { return new Manager(new RestClient.Builder() .withBaseUrl(credentials.environment(), AzureEnvironment.Endpoint.RESOURCE_MANAGER) .withCredentials(credentials) .withSerializerAdapter(new AzureJacksonAdapter()) .withResponseBuilderFactory(new AzureResponseBuilder.Factory()) .build()); } /**
/** * Creates an instance of ContainerInstanceManager that exposes resource management API entry points. * * @param credentials the credentials to use * @param subscriptionId the subscription * @return the ContainerInstanceManager */ public static ContainerInstanceManager authenticate(AzureTokenCredentials credentials, String subscriptionId) { return new ContainerInstanceManager(new RestClient.Builder() .withBaseUrl(credentials.environment(), AzureEnvironment.Endpoint.RESOURCE_MANAGER) .withCredentials(credentials) .withSerializerAdapter(new AzureJacksonAdapter()) .withResponseBuilderFactory(new AzureResponseBuilder.Factory()) .withInterceptor(new ProviderRegistrationInterceptor(credentials)) .withInterceptor(new ResourceManagerThrottlingInterceptor()) .build(), subscriptionId); }
/** * Creates an instance of MonitorManager that exposes Monitor API entry points. * * @param credentials the credentials to use * @param subscriptionId the subscription UUID * @return the MonitorManager */ public static MonitorManager authenticate(AzureTokenCredentials credentials, String subscriptionId) { return new MonitorManager(new RestClient.Builder() .withBaseUrl(credentials.environment(), AzureEnvironment.Endpoint.RESOURCE_MANAGER) .withCredentials(credentials) .withSerializerAdapter(new AzureJacksonAdapter()) .withResponseBuilderFactory(new AzureResponseBuilder.Factory()) .withInterceptor(new ProviderRegistrationInterceptor(credentials)) .build(), subscriptionId); } /**
/** * Creates an instance of ServiceBusManager that exposes servicebus management API entry points. * * @param credentials the credentials to use * @param subscriptionId the subscription UUID * @return the ServiceBusManager */ public static ServiceBusManager authenticate(AzureTokenCredentials credentials, String subscriptionId) { return new ServiceBusManager(new RestClient.Builder() .withBaseUrl(credentials.environment(), AzureEnvironment.Endpoint.RESOURCE_MANAGER) .withCredentials(credentials) .withSerializerAdapter(new AzureJacksonAdapter()) .withResponseBuilderFactory(new AzureResponseBuilder.Factory()) .withInterceptor(new ProviderRegistrationInterceptor(credentials)) .withInterceptor(new ResourceManagerThrottlingInterceptor()) .build(), subscriptionId); }
/** * Creates an instance of BatchAIManager that exposes BatchAI resource management API entry points. * * @param credentials the credentials to use * @param subscriptionId the subscription UUID * @return the BatchAIManager */ public static BatchAIManager authenticate(AzureTokenCredentials credentials, String subscriptionId) { return new BatchAIManager(new RestClient.Builder() .withBaseUrl(credentials.environment(), AzureEnvironment.Endpoint.RESOURCE_MANAGER) .withCredentials(credentials) .withSerializerAdapter(new AzureJacksonAdapter()) .withResponseBuilderFactory(new AzureResponseBuilder.Factory()) .withInterceptor(new ProviderRegistrationInterceptor(credentials)) .build(), subscriptionId); } /**
/** * Creates an instance of ContainerRegistryManager that exposes Registry resource management API entry points. * * @param credentials the credentials to use * @param subscriptionId the subscription * @return the SearchServiceManager */ public static SearchServiceManager authenticate(AzureTokenCredentials credentials, String subscriptionId) { return new SearchServiceManager(new RestClient.Builder() .withBaseUrl(credentials.environment(), AzureEnvironment.Endpoint.RESOURCE_MANAGER) .withCredentials(credentials) .withSerializerAdapter(new AzureJacksonAdapter()) .withResponseBuilderFactory(new AzureResponseBuilder.Factory()) .withInterceptor(new ProviderRegistrationInterceptor(credentials)) .withInterceptor(new ResourceManagerThrottlingInterceptor()) .build(), subscriptionId); }
/** * Creates an instance of DnsZoneManager that exposes DNS zone management API entry points. * * @param credentials the credentials to use * @param subscriptionId the subscription UUID * @return the DnsZoneManager */ public static DnsZoneManager authenticate(AzureTokenCredentials credentials, String subscriptionId) { return new DnsZoneManager(new RestClient.Builder() .withBaseUrl(credentials.environment(), AzureEnvironment.Endpoint.RESOURCE_MANAGER) .withCredentials(credentials) .withSerializerAdapter(new AzureJacksonAdapter()) .withResponseBuilderFactory(new AzureResponseBuilder.Factory()) .withInterceptor(new ProviderRegistrationInterceptor(credentials)) .withInterceptor(new ResourceManagerThrottlingInterceptor()) .build(), subscriptionId); }
/** * Creates an instance of ComputeManager that exposes Compute resource management API entry points. * * @param credentials the credentials to use * @param subscriptionId the subscription * @return the ComputeManager */ public static ComputeManager authenticate(AzureTokenCredentials credentials, String subscriptionId) { return new ComputeManager(new RestClient.Builder() .withBaseUrl(credentials.environment(), AzureEnvironment.Endpoint.RESOURCE_MANAGER) .withCredentials(credentials) .withSerializerAdapter(new AzureJacksonAdapter()) .withResponseBuilderFactory(new AzureResponseBuilder.Factory()) .withInterceptor(new ProviderRegistrationInterceptor(credentials)) .withInterceptor(new ResourceManagerThrottlingInterceptor()) .build(), subscriptionId); }
/** * Creates an instance of NetworkManager that exposes network resource management API entry points. * * @param credentials the credentials to use * @param subscriptionId the subscription UUID * @return the NetworkManager */ public static NetworkManager authenticate(AzureTokenCredentials credentials, String subscriptionId) { return new NetworkManager(new RestClient.Builder() .withBaseUrl(credentials.environment(), AzureEnvironment.Endpoint.RESOURCE_MANAGER) .withCredentials(credentials) .withSerializerAdapter(new AzureJacksonAdapter()) .withResponseBuilderFactory(new AzureResponseBuilder.Factory()) .withInterceptor(new ProviderRegistrationInterceptor(credentials)) .withInterceptor(new ResourceManagerThrottlingInterceptor()) .build(), subscriptionId); }
/** * Creates an instance of LocksManager that exposes Authorization resource management API entry points. * * @param credentials the credentials to use * @param subscriptionId the subscription UUID * @return the LocksManager */ public static LocksManager authenticate(AzureTokenCredentials credentials, String subscriptionId) { return new LocksManager(new RestClient.Builder() .withBaseUrl(credentials.environment(), AzureEnvironment.Endpoint.RESOURCE_MANAGER) .withCredentials(credentials) .withSerializerAdapter(new AzureJacksonAdapter()) .withResponseBuilderFactory(new AzureResponseBuilder.Factory()) .build(), subscriptionId); } /**
/** * Creates an instance of AuthorizationManager that exposes Authorization resource management API entry points. * * @param credentials the credentials to use * @param subscriptionId the subscription UUID * @return the AuthorizationManager */ public static AuthorizationManager authenticate(AzureTokenCredentials credentials, String subscriptionId) { return new AuthorizationManager(new RestClient.Builder() .withBaseUrl(credentials.environment(), AzureEnvironment.Endpoint.RESOURCE_MANAGER) .withCredentials(credentials) .withSerializerAdapter(new AzureJacksonAdapter()) .withResponseBuilderFactory(new AzureResponseBuilder.Factory()) .build(), subscriptionId); } /**
/** * Creates an instance of AppServiceManager that exposes Web resource management API entry points. * * @param credentials the credentials to use * @param subscriptionId the subscription UUID * @return the AppServiceManager */ public static AppServiceManager authenticate(AzureTokenCredentials credentials, String subscriptionId) { return new AppServiceManager(new RestClient.Builder() .withBaseUrl(credentials.environment(), AzureEnvironment.Endpoint.RESOURCE_MANAGER) .withCredentials(credentials) .withSerializerAdapter(new AzureJacksonAdapter()) .withResponseBuilderFactory(new AzureResponseBuilder.Factory()) .build(), subscriptionId); } /**
/** * Creates an instance of ResourcesManager that exposes Resources resource management API entry points. * * @param credentials the credentials to use * @param subscriptionId the subscription UUID * @return the ResourcesManager */ public static ResourcesManager authenticate(AzureTokenCredentials credentials, String subscriptionId) { return new ResourcesManager(new RestClient.Builder() .withBaseUrl(credentials.environment(), AzureEnvironment.Endpoint.RESOURCE_MANAGER) .withCredentials(credentials) .withSerializerAdapter(new AzureJacksonAdapter()) .withResponseBuilderFactory(new AzureResponseBuilder.Factory()) .build(), subscriptionId); } /**
protected RestClient buildRestClient(AzureTokenCredentials credentials, AzureEnvironment.Endpoint endpoint) { RestClient client = restClientBuilder .withBaseUrl(credentials.environment(), endpoint) .withCredentials(credentials) .withInterceptor(new ProviderRegistrationInterceptor(credentials)) .withInterceptor(new ResourceManagerThrottlingInterceptor()) .build(); if (client.httpClient().proxy() != null) { credentials.withProxy(client.httpClient().proxy()); } return client; }
protected RestClient buildRestClient(AzureTokenCredentials credentials, AzureEnvironment.Endpoint endpoint) { RestClient client = restClientBuilder .withBaseUrl(credentials.environment(), endpoint) .withCredentials(credentials) .withInterceptor(new ResourceManagerThrottlingInterceptor()) .build(); if (client.httpClient().proxy() != null) { credentials.withProxy(client.httpClient().proxy()); } return client; }
protected RestClient buildRestClient(AzureTokenCredentials credentials, AzureEnvironment.Endpoint endpoint) { RestClient client = restClientBuilder .withBaseUrl(credentials.environment(), endpoint) .withCredentials(credentials) .withInterceptor(new ProviderRegistrationInterceptor(credentials)) .withInterceptor(new ResourceManagerThrottlingInterceptor()) .build(); if (client.httpClient().proxy() != null) { credentials.withProxy(client.httpClient().proxy()); } return client; }