use of com.azure.core.management.profile.AzureProfile in project azure-maven-plugins by microsoft.
the class AbstractAzureResourceModule method getResourceManager.
protected static <R extends AzureConfigurable<R>, T extends Manager> T getResourceManager(final String subscriptionId, Supplier<AzureConfigurable<R>> configurableSupplier, AuthenticationMethod<R, T> authenticationMethod) {
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());
final TokenCredential tokenCredential = account.getTokenCredential(subscriptionId);
final R configurable = configurableSupplier.get().withPolicy(getUserAgentPolicy(userAgent)).withLogLevel(logLevel);
return authenticationMethod.apply(configurable, tokenCredential, azureProfile);
}
use of com.azure.core.management.profile.AzureProfile in project DataSpaceConnector by eclipse-dataspaceconnector.
the class AzureResourceManagerExtension method initialize.
@Override
public void initialize(ServiceExtensionContext context) {
var tenantId = requiredSetting(context, "edc.azure.tenant.id");
var subscriptionId = requiredSetting(context, "edc.azure.subscription.id");
// Detect credential source based on runtime environment, e.g. Azure CLI, environment variables
var credential = new DefaultAzureCredentialBuilder().build();
var azure = AzureEnvironment.AZURE;
var profile = new AzureProfile(tenantId, subscriptionId, azure);
var resourceManager = AzureResourceManager.authenticate(credential, profile).withSubscription(subscriptionId);
context.registerService(AzureEnvironment.class, azure);
context.registerService(TokenCredential.class, credential);
context.registerService(AzureProfile.class, profile);
context.registerService(AzureResourceManager.class, resourceManager);
}
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;
}
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;
}
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;
}
Aggregations