A production key stored as a variable can show up in build logs. An ID stored as a secret makes it harder to check which account the pipeline uses during an incident.
Every setting needs two decisions:
A secret is any value that lets whoever holds it do something: sign in, read data, write data, spend your money, or send data in your name. Everything else is a variable. It names or locates something, and access still needs a credential.
A quick check: if this value leaked, would you want to replace it? A leaked client secret means an urgent rotation. A leaked tenant ID means nothing, because there is nothing to change. If the answer is yes, it is a secret, even when the service doesn't let you rotate it.
During a failed deployment, you can read variables back, compare them across environments, or check them in the logs. Secrets are write-only, and the pipeline masks them in logs.
| Variable | Secret |
|---|---|
| Tenant ID | App registration client secret or certificate |
| Subscription ID | Storage account access key or connection string |
| Resource group name | SQL connection string with a password |
| Resource names (App Service, Key Vault, storage account) | Azure OpenAI or AI Foundry API key |
| App registration client ID | SAS token |
The client ID is a variable even when the app also has a client secret. The secret is what lets someone sign in, and the ID only says which app to sign in as. Better still, sign in with OIDC, so there is no client secret to store at all. See Do you deploy to Azure from GitHub Actions with OIDC instead of secrets?
Use names that show whether a value is safe to share and what access it grants.
A name that contradicts itself answers neither. NEXT_PUBLIC_SEARCH_ADMIN_KEY says "public" and "admin key" at once. The next developer can't tell which half is true, so they guess. If they guess public, they paste it into browser code or a log. If they guess secret, they hide a harmless value that nobody can check later.
Some names also change what happens to the value. In Next.js, a setting that starts with NEXT_PUBLIC_ is built into any browser JavaScript that reads it, even when it is stored as a GitHub secret. Some tools go further and copy every public-prefixed value into their own bundles. Vite (VITE_), Create React App (REACT_APP_) and Expo (EXPO_PUBLIC_) work the same way. A wrong prefix doesn't just mislead people, it publishes the value.
Names also decide how fast you can respond to a leak. To rotate a key, you have to find every copy of it: the GitHub secret, the Key Vault entry, the App Service setting. That search only works when every copy has the same honest name. The copy stored under another name is the one nobody rotates.
SEARCH_ADMIN_KEY and SEARCH_QUERY_KEY, not SEARCH_KEYenv:NEXT_PUBLIC_SEARCH_ADMIN_KEY: ${{ secrets.SEARCH_ADMIN_KEY }}
❌ Figure: Bad example - The name says both public and admin, and the prefix wins: the key is built into the public JavaScript bundle
env:NEXT_PUBLIC_SEARCH_INDEX_NAME: ${{ vars.NEXT_PUBLIC_SEARCH_INDEX_NAME }}SEARCH_ADMIN_KEY: ${{ secrets.SEARCH_ADMIN_KEY }}
✅ Figure: Good example - Each name tells the truth. Only the harmless index name reaches the browser, and the key stays on the server
A secret must never reach client code, whatever it is called. If the browser truly needs a value, it is public, so make sure it can do no real harm.
Ask: does staging need a different value from production?
One value, one place. A shared value copied into each environment is two copies that drift apart without anyone noticing.
For secrets, the scope follows the infrastructure behind them. Give staging and production their own resources, each with its own key. Then a staging deployment, a pull request preview or a leaked staging key can't touch production. Store each key at environment level, so only jobs that name that environment can read it.
If both environments share one resource and one key, store the key once at repository level. That tells the next person the truth: the infrastructure is shared, and anything that can deploy staging can reach production. Copying the key into each environment hides that, and leaves two copies to rotate. To separate the environments, split the resource or give each environment its own key limited to its own part. Moving the secret to another scope doesn't separate anything.
| Setting | Scope | Why |
|---|---|---|
| Tenant ID | Shared | Every environment signs in to the same tenant |
| Resource group name | Environment | Each environment deploys to its own resource group |
| Client ID of the deployment identity | Environment | Each environment signs in with its own identity |
| Database connection string | Environment | Each environment has its own database |
| Search admin key, when both environments use one search service | Shared | The search service is shared, and the scope says so |
✅ Figure: Good example - The scope of each setting matches the infrastructure behind it, including a search service that is still shared and should be split