How to generate a bearer token on Azure container instance to access

NS 40 Reputation points

I need to access public API from the Azure Container Instance.
It appears that this API needs a Bearer Token.

How can we generate the bearer token for this API from the ACI container.

Azure Container Instances
Azure Container Instances
An Azure service that provides customers with a serverless container experience.
648 questions
0 comments No comments
{count} votes

Accepted answer
  1. TP 78,976 Reputation points


    The access token is the Bearer token. For example, in your previous question I showed how to retrieve access token via IMDS. Once you have this access token, you can add it in the Authorization header in the request to REST API.

    Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6Ii1LSTNROW5OUjdiUm9meG1lWm9YcWJIWkdldyIsImtpZCI6Ii1LSTNROW5OUjdiUm9meG1lWm9YcWJIWkdldyJ9.eyJhdWQiOiJodHRwczovL21hbm

    Curl command would be similar to below:

    curl -v -s -H "Authorization: Bearer ${access_token}" -H "Content-Type: application/json"${subscription_id}/providers/Microsoft.ContainerInstance/containerGroups?api-version=2023-05-01

    Please click Accept Answer and upvote if the above was helpful.



0 additional answers

Sort by: Most helpful