Azure Management REST API - "Authentication failed. The 'Authorization' header is provided in an invalid format."
Asked Answered
M

2

19

I am desperately trying to move 2 classic storage accounts from my old MSDN subscription to my MPN subscription and I keep hitting a brick wall as move is only supported for these through REST APIs.

I have enabled the APIs following the instructions here....

https://azure.microsoft.com/en-us/documentation/articles/resource-group-move-resources/

and here...

https://msdn.microsoft.com/en-us/library/azure/dn776326.aspx

but am completely flummoxed. I have created a POST request as suggested to check status as the first call in the 'move resources' instructions...

POST https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.ClassicCompute/validateSubscriptionMoveAvailability

(with the subscriptionId replaced with the ID for each) and passing the appropriate source / target body in.

I have also provided the Authorization header as follows...

Authorization: {key as generated by the Azure portal}

Completely lost now. I have tried using both Fiddler & Postman. PowerShell isn't an option for me because I don't know it at all. I just want to move 2 items over and so far just having these management APIs running has cost me over £15 and my website is on the verge of going down as my credit will soon expire.

Any help would be most appreciated.

Mochun answered 2/10, 2016 at 23:47 Comment(0)
L
7

Per your description, it seems that there is any thing wrong of the way you generate:

Authorization: {key as generated by the Azure portal}

According the document description at https://msdn.microsoft.com/en-us/library/azure/dn790569.aspx#bk_common, the authorization header should be a JSON Web Token that you obtain from Azure Active Directory, but directly from Azure Portal.

You can refer to https://azure.microsoft.com/en-us/documentation/articles/active-directory-protocols-oauth-code/ for how to obtain a JWT from AAD.

And the Authorization header should be in like: Authorization : Bearer {JWT}.

Longheaded answered 3/10, 2016 at 2:58 Comment(6)
I can't make head nor tail of any of this I'm afraid. It would make sense to me if I was trying to write my own API but I'm not, I'm trying to use the management API. According to the instructions I read the Authorization header should be as provided by the key generator in the old Azure portal.Mochun
Reading more into this, the code I get from the portal is supposed (I think) to be the encoded JWT.Mochun
Thanks Gary - In the end I just gave up on this due to it being insanely over complicated and created a new storage account in the new subscription and copied everything over as I wasn't dealing with a large amount of data.Mochun
Hi, how did you added authorization in api url?, Authorization: {key as generated by the Azure portal}Moralist
@PriyankaMane, set Authorization in the request headers which against to your api url.Longheaded
@KeithJackson, Please generate the token by clicking on "Try it" in the same page where Gary provided his linksMaritamaritain
B
0

My Error got resolved when i added the required params ,you'll find the keys on azure portal enter image description here

Burkhardt answered 26/5, 2023 at 3:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.