New-AzureRmADApplication : Resource not found for the segment 'me'

I am getting following error when i run through octopus azure powershell command.
New-AzureRmADApplication : Resource not found for the segment ‘me’
I am using Octopus 2018.6.3

This works through powershell command when i run on octopus server with same azure account with no issues.

Not sure what is different when it run through octopus Azure powershell command as it takes the principle account.

Hi Amjad, thanks for reaching out.

You mentioned that you were able to get this to work when running with the same Azure account, is this an interactive login? You should be able to experience the same problem if you were to log in using the service principal account. Do you experience the same problem from the command line if you did something like the following?

param (

$credentials = New-Object System.Management.Automation.PSCredential ($applicationId, (ConvertTo-SecureString $applicationKey -AsPlainText -Force))
Login-AzureRmAccount -Credential $credentials -TenantId $tenantId -SubscriptionId $subscriptionId -ServicePrincipal

$newAppPassword = ConvertTo-Securestring -string (New-Guid) -AsPlainText -Force
New-AzureRmADApplication -DisplayName "Example" -HomePage "" -IdentifierUris "http://example" -Password $newAppPassword

If you get the same problem, then the issue is with the service principal account and the associated permissions. If this is the case then the Microsoft documentation may be able to shed some light on the topic. If however, the above script runs fine for you, then we will have to investigate further.

Please let me know if that helps! :slight_smile: