grant-local-rbac.sh — auto-detect storage / ACR from azd env
Motivation¶
Running scripts/dev/grant-local-rbac.sh directly on a fresh azd up
deployment failed with:
The script's hard-coded defaults match the docs/auth.md example
(elbstg01 / rg-elb-01 / elbacr01 / rg-elbacr-01), not the
auto-suffixed names produced by azd up
(stelbdashboard… / acrelbdashboard… / rg-elb-dashboard). The
wrapper local-debug-auth.sh already auto-detected from
azd env get-values, so users hitting the standalone script had a
worse experience than users going through the wrapper.
User-facing change¶
scripts/dev/grant-local-rbac.sh (no flag changes) now resolves the
workload names in this order:
- Explicit
--storage/--storage-rg/--acr/--acr-rgflags (unchanged). azd env get-valueskeysSTORAGE_ACCOUNT_NAME,AZURE_RESOURCE_GROUP,ACR_NAMEwhen those flags are not set.- Docs example defaults (
elbstg01/rg-elb-01/elbacr01/rg-elbacr-01) as a final fallback. - If the chosen storage / ACR does not exist and exactly one
stelbdashboard*/acrelbdashboard*resource is reachable in the subscription, use that and print anauto-resolvednotice.
This matches the resolution logic already present in
scripts/dev/local-debug-auth.sh so both entry points behave the same.
API / IaC diff summary¶
scripts/dev/grant-local-rbac.sh- Initial
STORAGE/STORAGE_RG/ACR/ACR_RGare now empty; docs example values become*_DEFAULTfallbacks. - Added an
azd env get-valuesblock (usesazdonly if installed) that fills any unset name before the docs defaults apply. - Added a
stelbdashboard*single-match fallback and a symmetricacrelbdashboard*fallback for ACR.
No flag, no help text, no behavioural change for callers that already
pass explicit flags (including local-debug-auth.sh).
Validation evidence¶
bash -n scripts/dev/grant-local-rbac.sh— clean.scripts/dev/grant-local-rbac.sh --dry-runagainst the activerg-elb-dashboarddeployment:
auto-resolved storage: stelbdashboard3abp67bppe (rg: rg-elb-dashboard)
auto-resolved acr: acrelbdashboard3abp67bppe (rg: rg-elb-dashboard)
…
Summary: created=0 skipped=5 failed=0
All five role assignments (Storage Blob / Table Data Contributor, Storage Account Contributor, Reader on RG, AcrPull on ACR) were recognised as already present.