use of com.microsoft.azure.hdinsight.sdk.rest.azure.datalake.analytics.accounts.models.DataLakeAnalyticsAccount in project azure-tools-for-java by Microsoft.
the class AzureSparkServerlessAccount method getStorageRootPath.
@Nullable
public String getStorageRootPath() {
String storageRootPath = null;
DataLakeAnalyticsAccount accountDetail = this.getDetailResponse();
if (accountDetail != null) {
// find default storage account name and suffix
String defaultStorageAccountName = accountDetail.defaultDataLakeStoreAccount();
storageRootPath = accountDetail.dataLakeStoreAccounts().stream().filter(info -> info.name().equals(defaultStorageAccountName)).findFirst().map(DataLakeStoreAccountInformation::suffix).map(suffix -> String.format("adl://%s.%s/", defaultStorageAccountName, suffix)).orElse(null);
}
return storageRootPath;
}
use of com.microsoft.azure.hdinsight.sdk.rest.azure.datalake.analytics.accounts.models.DataLakeAnalyticsAccount in project azure-tools-for-java by Microsoft.
the class SynapseCosmosSparkPool method getConfigurationInfo.
@Override
public void getConfigurationInfo() throws IOException {
if (!isConfigInfoAvailable()) {
// Extract Subscription ID from ADLA resource ID
// Sample adlaResouceId: /subscriptions/a00b00a0-00a0-0000-b000-a000b0a00000/resourceGroups/testRG/providers/Microsoft.DataLakeAnalytics/accounts/testAccount
Matcher matcher = ADLA_RESOURCE_ID_PATTERN.matcher(getAdlaResourceId());
if (!matcher.matches()) {
String errorMsg = String.format("ADLA resource ID doesn't match with pattern. AdlaResourceId: %s. Pattern: %s", getAdlaResourceId(), ADLA_RESOURCE_ID_PATTERN);
throw new IOException(errorMsg);
}
String subscriptionId = matcher.group("sid");
// Get SubscriptionDetail from subscription ID
AzureManager azureManager = AuthMethodManager.getInstance().getAzureManager();
SubscriptionManager subscriptionManager = azureManager.getSubscriptionManager();
SubscriptionDetail subscription = subscriptionManager.getSubscriptionIdToSubscriptionDetailsMap().getOrDefault(subscriptionId, null);
if (subscription == null) {
throw new IOException("User has no permission to access subscription " + subscriptionId + ".");
}
// Get ADLA account details through Azure REST API
AzureHttpObservable managementHttp = new AzureManagementHttpObservable(subscription, ApiVersion.VERSION);
String resourceManagerEndpoint = CommonSettings.getAdEnvironment().resourceManagerEndpoint();
URI accountDetailUri = URI.create(resourceManagerEndpoint).resolve(getAdlaResourceId());
AzureSparkServerlessAccount azureSparkServerlessAccount = managementHttp.withUuidUserAgent().get(accountDetailUri.toString(), null, null, DataLakeAnalyticsAccount.class).doOnError(err -> log().warn("Error getting ADLA account details with error: " + err.getMessage())).map(dataLakeAnalyticsAccount -> new AzureSparkServerlessAccount(subscription, URI.create("https://" + dataLakeAnalyticsAccount.endpoint()), dataLakeAnalyticsAccount.name()).setDetailResponse(dataLakeAnalyticsAccount)).subscribeOn(Schedulers.io()).toBlocking().singleOrDefault(null);
// Get default storage account info from ADLA account
String storageRootPath = azureSparkServerlessAccount.getStorageRootPath();
IHDIStorageAccount adlsGen1StorageAccount = storageRootPath == null ? null : new AzureSparkCosmosCluster.StorageAccount(azureSparkServerlessAccount.getDetailResponse().defaultDataLakeStoreAccount(), storageRootPath, azureSparkServerlessAccount.getSubscription().getSubscriptionId());
synchronized (this) {
if (!isConfigInfoAvailable()) {
this.http = managementHttp;
this.storageAccount = adlsGen1StorageAccount;
isConfigInfoAvailable = true;
}
}
}
}
Aggregations