use of com.azure.core.management.profile.AzureProfile in project azure-maven-plugins by microsoft.
the class AzureSpringCloud method getClient.
@Cacheable(cacheName = "asc/{}/client", key = "$subscriptionId")
@AzureOperation(name = "springcloud.get_client.subscription", params = "subscriptionId", type = AzureOperation.Type.SERVICE)
protected SpringServices getClient(final String subscriptionId) {
final Account account = Azure.az(AzureAccount.class).account();
final AzureConfiguration config = Azure.az().config();
final String userAgent = config.getUserAgent();
final HttpLogDetailLevel logLevel = Optional.ofNullable(config.getLogLevel()).map(HttpLogDetailLevel::valueOf).orElse(HttpLogDetailLevel.NONE);
final AzureProfile azureProfile = new AzureProfile(null, subscriptionId, account.getEnvironment());
return AppPlatformManager.configure().withHttpClient(AzureService.getDefaultHttpClient()).withLogLevel(logLevel).withPolicy(// set user agent with policy
getUserAgentPolicy(userAgent)).authenticate(account.getTokenCredential(subscriptionId), azureProfile).springServices();
}
use of com.azure.core.management.profile.AzureProfile in project azure-maven-plugins by microsoft.
the class SqlServerManagerFactory method create.
@Cacheable(cacheName = "SqlServerManager", key = "$subscriptionId")
public static SqlServerManager create(String subscriptionId) {
final Account account = Azure.az(AzureAccount.class).account();
final AzureConfiguration config = Azure.az().config();
final String userAgent = config.getUserAgent();
final HttpLogDetailLevel logLevel = Optional.ofNullable(config.getLogLevel()).map(HttpLogDetailLevel::valueOf).orElse(HttpLogDetailLevel.NONE);
final AzureProfile azureProfile = new AzureProfile(null, subscriptionId, account.getEnvironment());
return SqlServerManager.configure().withHttpClient(AzureService.getDefaultHttpClient()).withLogLevel(logLevel).withPolicy(getUserAgentPolicy(userAgent)).authenticate(account.getTokenCredential(subscriptionId), azureProfile);
}
use of com.azure.core.management.profile.AzureProfile in project azure-vm-agents-plugin by jenkinsci.
the class AzureClientUtil method getAzureResourceManager.
private static AzureResourceManager getAzureResourceManager(AzureBaseCredentials azureCredentials, String subscriptionId) {
AzureProfile profile = new AzureProfile(azureCredentials.getAzureEnvironment());
TokenCredential tokenCredential = AzureCredentials.getTokenCredential(azureCredentials);
AzureResourceManager.Authenticated builder = AzureResourceManager.configure().withHttpClient(HttpClientRetriever.get()).authenticate(tokenCredential, profile);
if (Util.fixEmpty(subscriptionId) == null) {
return builder.withDefaultSubscription();
}
return builder.withSubscription(subscriptionId);
}
Aggregations