use of com.microsoft.azure.toolkit.lib.account.IAccount in project azure-maven-plugins by microsoft.
the class IAzureBaseResource method portalUrl.
default String portalUrl() {
final IAccount account = Azure.az(IAzureAccount.class).account();
Subscription subscription = account.getSubscription(this.subscriptionId());
return account.portalUrl() + REST_SEGMENT_JOB_MANAGEMENT_TENANTID + subscription.getTenantId() + REST_SEGMENT_JOB_MANAGEMENT_RESOURCE + this.id();
}
use of com.microsoft.azure.toolkit.lib.account.IAccount in project azure-maven-plugins by microsoft.
the class AzureService method getResourceManager.
@Cacheable(cacheName = "resource/{}/manager", key = "$subscriptionId")
default ResourceManager getResourceManager(String subscriptionId) {
// make sure it is signed in.
final IAccount account = az(IAzureAccount.class).account();
final AzureConfiguration config = Azure.az().config();
final String userAgent = config.getUserAgent();
final HttpLogDetailLevel logDetailLevel = config.getLogLevel() == null ? HttpLogDetailLevel.NONE : HttpLogDetailLevel.valueOf(config.getLogLevel());
final AzureProfile azureProfile = new AzureProfile(account.getEnvironment());
final Providers providers = ResourceManager.configure().withHttpClient(getDefaultHttpClient()).withPolicy(getUserAgentPolicy(userAgent)).authenticate(account.getTokenCredential(subscriptionId), azureProfile).withSubscription(subscriptionId).providers();
return ResourceManager.configure().withHttpClient(getDefaultHttpClient()).withLogLevel(logDetailLevel).withPolicy(// set user agent with policy
getUserAgentPolicy(userAgent)).withPolicy(// add policy to auto register resource providers
new ProviderRegistrationPolicy(providers)).authenticate(account.getTokenCredential(subscriptionId), azureProfile).withSubscription(subscriptionId);
}
Aggregations