I am trying to check whether the DataLake Analytics account State is active or not with the below power shell script through Service Principal authentication. Application is given the access to datalake analytics account. And it is present in one of the resource groups in my subscription. When I am trying to run the below command, I am getting the error that analytics account is not present in any resource group.But I am seeing this error only some times but not always. I dont think this behavior is due to network issues as script was running fine earlier.
Note: I am seeing this error after the existing DataLakeStore and Analytics accounts have become Gen1. Can some one help me why I am getting this error?
System.Net.WebRequest]::DefaultWebProxy.Credentials = [System.Net.CredentialCache]::DefaultCredentials;
Login-AzureRmAccount -ServicePrincipal -TenantId 'Tenant' -ApplicationId 'ApplicationID' -CertificateThumbprint 'Certificate' -ErrorAction Stop > $null ;
$Status = Get-AzureRmDataLakeAnalyticsAccount -Name 'ADLAccount'
-ErrorAction Stop -ErrorVariable ErrorStatus;
if($Status.State -ne 'Active'){
Write-Error ('Error Occurred while connecting to DataLake analytics account::ADLAAccount');}
}
Catch{
Write-Error ($_.Exception.Message +';'+ $_.InvocationInfo.PositionMessage);
}
Could not find account: 'ADLAAccount' in any resource group in the currently selected subscription: subscriprionID. Please ensure this account exists and that the current user has access to it.;At 'AppID' - CertificateThumbprint 'Thumbprint' -ErrorAction Stop > $null ;