Store an Azure Service principal using the REST api

hi, should I be able to do this?

I’ve worked out how to return the existing accounts, so i copied the attributes into the header and every time i send the POST, it errors with a 500 internal server error.

I dont know enough to be able to work out if its possible to interpret the 500 error and work out whats wrong.

some fairly industrial code im using to see if this works.


$OctopusURL = 'http://dllwindows8'

$OctopusAPIKey = 'API-XXXXXXXXXXXXXXXXXXXXXXXXX'

$header = @{}
$header.Add("X-Octopus-ApiKey", $OctopusAPIKey);
$header.Add("AccountType", "AzureServicePrincipal")
$header.Add("SubscriptionNumber", "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")
$header.Add("ClientId", "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")
$header.Add("TenantId", "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")
$header.Add("Name", "Rest Insertion")
#$header.Add("Password", "Rest Insertion")
#$header.Add("Description", "Description")


$AzureSubscriptionAccount = (Invoke-WebRequest "$OctopusURL/api/accounts" -Method POST -Headers $header).content | ConvertFrom-Json
$AzureSubscriptionAccount

HI there,

Thanks for reaching out. Totally possible to do from the API, but not quite with that script. Here I wrote an example for you:

Cheers!
Dalmiro

Notice:

This issue has been closed due to inactivity. If you encounter the same or a similar issue and require help, please open a new discussion (if we asked for logs or extra details in this thread, consider including them in the new thread). If you are the creator of this thread and believe it should not be closed let us know via our support email.