Search in sources :

Example 1 with AzureProfile

use of com.azure.core.management.profile.AzureProfile in project terra-workspace-manager by DataBiosphere.

the class CrlService method buildRelayManager.

private RelayManager buildRelayManager(AzureCloudContext azureCloudContext, AzureConfiguration azureConfig) {
    TokenCredential azureCreds = getManagedAppCredentials(azureConfig);
    AzureProfile azureProfile = new AzureProfile(azureCloudContext.getAzureTenantId(), azureCloudContext.getAzureSubscriptionId(), AzureEnvironment.AZURE);
    // We must use FQDN because there are two `Defaults` symbols imported otherwise.
    RelayManager manager = bio.terra.cloudres.azure.resourcemanager.relay.Defaults.crlConfigure(clientConfig, RelayManager.configure()).authenticate(azureCreds, azureProfile);
    return manager;
}
Also used : RelayManager(com.azure.resourcemanager.relay.RelayManager) AzureProfile(com.azure.core.management.profile.AzureProfile) TokenCredential(com.azure.core.credential.TokenCredential)

Example 2 with AzureProfile

use of com.azure.core.management.profile.AzureProfile in project terra-workspace-manager by DataBiosphere.

the class CrlService method buildComputeManager.

private ComputeManager buildComputeManager(AzureCloudContext azureCloudContext, AzureConfiguration azureConfig) {
    TokenCredential azureCreds = getManagedAppCredentials(azureConfig);
    AzureProfile azureProfile = new AzureProfile(azureCloudContext.getAzureTenantId(), azureCloudContext.getAzureSubscriptionId(), AzureEnvironment.AZURE);
    // We must use FQDN because there are two `Defaults` symbols imported otherwise.
    ComputeManager manager = bio.terra.cloudres.azure.resourcemanager.common.Defaults.crlConfigure(clientConfig, ComputeManager.configure()).authenticate(azureCreds, azureProfile);
    return manager;
}
Also used : AzureProfile(com.azure.core.management.profile.AzureProfile) TokenCredential(com.azure.core.credential.TokenCredential) ComputeManager(com.azure.resourcemanager.compute.ComputeManager)

Example 3 with AzureProfile

use of com.azure.core.management.profile.AzureProfile in project terra-workspace-manager by DataBiosphere.

the class CrlService method buildResourceManager.

/**
 * Get a resource manager pointed at the MRG subscription
 *
 * @param azureCloudContext target cloud context
 * @return azure resource manager
 */
public ResourceManager buildResourceManager(AzureCloudContext azureCloudContext, AzureConfiguration azureConfig) {
    TokenCredential azureCreds = getManagedAppCredentials(azureConfig);
    AzureProfile azureProfile = new AzureProfile(azureCloudContext.getAzureTenantId(), azureCloudContext.getAzureSubscriptionId(), AzureEnvironment.AZURE);
    // We must use FQDN because there are two `Defaults` symbols imported otherwise.
    ResourceManager manager = bio.terra.cloudres.azure.resourcemanager.common.Defaults.crlConfigure(clientConfig, ResourceManager.configure()).authenticate(azureCreds, azureProfile).withSubscription(azureCloudContext.getAzureSubscriptionId());
    return manager;
}
Also used : AzureProfile(com.azure.core.management.profile.AzureProfile) ResourceManager(com.azure.resourcemanager.resources.ResourceManager) TokenCredential(com.azure.core.credential.TokenCredential)

Example 4 with AzureProfile

use of com.azure.core.management.profile.AzureProfile in project azure-maven-plugins by microsoft.

the class RedisManagerFactory method create.

@Cacheable(cacheName = "RedisManager", key = "$subscriptionId")
public static RedisManager 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 RedisManager.configure().withHttpClient(AzureService.getDefaultHttpClient()).withLogLevel(logLevel).withPolicy(getUserAgentPolicy(userAgent)).authenticate(account.getTokenCredential(subscriptionId), azureProfile);
}
Also used : AzureAccount(com.microsoft.azure.toolkit.lib.auth.AzureAccount) Account(com.microsoft.azure.toolkit.lib.auth.Account) AzureConfiguration(com.microsoft.azure.toolkit.lib.AzureConfiguration) HttpLogDetailLevel(com.azure.core.http.policy.HttpLogDetailLevel) AzureProfile(com.azure.core.management.profile.AzureProfile) AzureAccount(com.microsoft.azure.toolkit.lib.auth.AzureAccount) Cacheable(com.microsoft.azure.toolkit.lib.common.cache.Cacheable)

Example 5 with AzureProfile

use of com.azure.core.management.profile.AzureProfile in project azure-maven-plugins by microsoft.

the class MySqlManagerFactory method create.

@Cacheable(cacheName = "MySqlManager", key = "$subscriptionId")
public static MySqlManager 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 MySqlManager.configure().withHttpClient(AzureService.getDefaultHttpClient()).withLogOptions(new HttpLogOptions().setLogLevel(logLevel)).withPolicy(getUserAgentPolicy(userAgent)).authenticate(account.getTokenCredential(subscriptionId), azureProfile);
}
Also used : AzureAccount(com.microsoft.azure.toolkit.lib.auth.AzureAccount) Account(com.microsoft.azure.toolkit.lib.auth.Account) AzureConfiguration(com.microsoft.azure.toolkit.lib.AzureConfiguration) HttpLogDetailLevel(com.azure.core.http.policy.HttpLogDetailLevel) AzureProfile(com.azure.core.management.profile.AzureProfile) AzureAccount(com.microsoft.azure.toolkit.lib.auth.AzureAccount) HttpLogOptions(com.azure.core.http.policy.HttpLogOptions) Cacheable(com.microsoft.azure.toolkit.lib.common.cache.Cacheable)

Aggregations

AzureProfile (com.azure.core.management.profile.AzureProfile)17 HttpLogDetailLevel (com.azure.core.http.policy.HttpLogDetailLevel)9 TokenCredential (com.azure.core.credential.TokenCredential)8 AzureConfiguration (com.microsoft.azure.toolkit.lib.AzureConfiguration)8 Account (com.microsoft.azure.toolkit.lib.auth.Account)8 AzureAccount (com.microsoft.azure.toolkit.lib.auth.AzureAccount)8 Cacheable (com.microsoft.azure.toolkit.lib.common.cache.Cacheable)8 AzureResourceManager (com.azure.resourcemanager.AzureResourceManager)3 HttpLogOptions (com.azure.core.http.policy.HttpLogOptions)2 ProviderRegistrationPolicy (com.azure.resourcemanager.resources.fluentcore.policy.ProviderRegistrationPolicy)2 Providers (com.azure.resourcemanager.resources.models.Providers)2 AzureOperation (com.microsoft.azure.toolkit.lib.common.operation.AzureOperation)2 ClientSecretCredentialBuilder (com.azure.identity.ClientSecretCredentialBuilder)1 ManagedIdentityCredential (com.azure.identity.ManagedIdentityCredential)1 ManagedIdentityCredentialBuilder (com.azure.identity.ManagedIdentityCredentialBuilder)1 ComputeManager (com.azure.resourcemanager.compute.ComputeManager)1 RelayManager (com.azure.resourcemanager.relay.RelayManager)1 ResourceManager (com.azure.resourcemanager.resources.ResourceManager)1 Subscription (com.azure.resourcemanager.resources.models.Subscription)1 StorageManager (com.azure.resourcemanager.storage.StorageManager)1