Siegfried Heintze Thanks for posting your question in Microsoft Q&A. I assume you are using GitHub Actions for Azure to create workflows for your deployment to Azure. From the description above, you are looking to generate access token in the workflow and make a call to Azure APIM (Azure Function as backend API).
Let me start with the part - 1 (generating access token)
Using Azure login action, you can achieve this with two different ways:
- Service Principal with secrets
- Connect OpenID Connect with Azure Service Principal using a Federated Identity Credential
Here is doc: Use GitHub Actions to connect to Azure with detailed step by step guide and also, https://github.com/marketplace/actions/azure-login has more info on this scenario. Make sure that you specify optional audience
parameter as APIM when generating the token (so that it rightly validates in APIM via validate-jwt
policy).
part -2 (make REST API call)
You can make a rest API call to API Management from Azure CLI action with inline script or explore HTTP Request Action if it fits your scenario with generated access token.
To answer your questions (in the order)
- The device login flow cannot be used in your scenario and client credential flow is the best option for web application/non-interactive scenario as described in the doc.
- Not really an expert in GitHub actions or related testing framework. I suggest you explore https://docs.github.com/en/actions/automating-builds-and-tests/about-continuous-integration or https://github.com/orgs/community/discussions and community experts can help in answering this.
- The role contributor should be sufficient, and you can add
--json-auth
parameter as described in the doc: Configure a service principal with a secret or pass as individual parameters to address security concerns (the same has been described in the referenced doc).
I hope this helps and let me know if you have any questions.