I am trying to automate rotation of client secret for an Azure app using a Github Workflow. This Workflow will create a new client secret in ever 90 days and update the secret which is stored in a KV. But after creating a workflow and successful login into Azure using OIDC, I get the following error:
Run CLIENT_SECRET=$(az ad app credential reset --id "***" --append --display-name "GitHubWorkflowSecret" --end-date "$(date -u -d '+90 days' +'%Y-%m-%dT%H:%M:%SZ')") ERROR: Insufficient privileges to complete the operation.
I created a federated credentials for OIDC for Github Workflow and used it in the workflow like mentioned in the github documentation (https://docs.github.com/en/actions/security-for-github-actions/security-hardening-your-deployments/configuring-openid-connect-in-azure):
name: Azure OIDC Workflow
on:
push:
branches:
- "***"
permissions:
id-token: write
contents: read
jobs:
create-client-secret-and-update-kv:
runs-on: "***"
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Login to Azure using OIDC
uses: azure/login@v1
with:
client-id: "***"
tenant-id: "****"
allow-no-subscriptions: true
- name: Create Client Secret for Azure AD App
id: create-secret
run: |
CLIENT_SECRET=$(az ad app credential reset --id "***" --append --display-name "GitHubWorkflowSecret" --end-date "$(date -u -d '+90 days' +'%Y-%m-%dT%H:%M:%SZ')")
I had to bypass subscription_id because the app is a service principle. I could login but the step where I am trying to create a client secret is failing due to insufficient privileges. I thought having a federated OIDC secret would be enough to at least get the permission to create a client secret, but it isn't the case. Apologies if this is a dumb question, I am new to Azure and confused about why there is an issue with permission here. Some guidance would be of great help to me. Thanks!
