microsoft / microsoft/aspire

Azure provisioning: generated "*-roles" (RBAC) modules emit a Bicep "no-unused-params" warning for the always-added location parameter

Open
#19,242 1 comment 0 reactions 0 assignees View on GitHub
area-integrations triage:bot-seen
Dominant language
C#
Stars
6.3k
Forks
991
Avg merge
2d 15h
Merged PRs (30d)
196

Description

### Describe the bug

Every Azure provisioning run emits a Bicep linter warning from `az bicep build` for the generated role-assignment module:

```
WARNING: ...-roles.module.bicep(2,7) : Warning no-unused-params: Parameter "location" is declared but never used. [https://aka.ms/bicep/linter-diagnostics#no-unused-params]
```

### Root cause

`AzureResourceInfrastructure` unconditionally adds a `location` parameter to **every** generated module — [`AzureResourceInfrastructure.cs` L20-27](https://github.com/microsoft/aspire/blob/cfbf1c432e94dfe4a3261593eeef8c93913079bb/src/Aspire.Hosting.Azure/AzureResourceInfrastructure.cs#L20-L27):

```csharp
// Always add a default location parameter.
// azd assumes there will be a location parameter for every module.
// The Infrastructure location resolver will resolve unset Location properties to this parameter.
Add(new ProvisioningParameter("location", typeof(string))
{
Description = "The location for the resource(s) to be deployed.",
Value = BicepFunction.GetResourceGroup().Location
});
```

The role-assignment (RBAC) module — created as `{targetResource.Name}-roles` in `AzureResourcePreparer.CreateGlobalRoleAssignmentsResource` — is also an `AzureResourceInfrastructure`, so it inherits this `location` parameter, but role assignments don't reference `location`, so Bicep's `no-unused-params` rule flags it on every provisioning.

### Impact

Cosmetic but persistent: a WARNING on every `aspire run` / `aspire publish` that provisions Azure resources with role assignments. It adds noise that can mask genuinely important bicep warnings.

### Expected behavior

No linter warning for generated modules. Options include suppressing `no-unused-params` for generated modules (bicepconfig / `#disable-next-line`), only adding the `location` parameter to modules that use it, or otherwise reconciling the azd "every module has a location parameter" assumption with the linter.

### Steps to reproduce

1. AppHost with any Azure resource that generates role assignments, e.g. `builder.AddAzureStorage("storage")`.
2. `aspire run` (or `aspire publish`) with real provisioning.
3. Observe the `az bicep build` stderr WARNING for `-roles.module.bicep` — `no-unused-params` on `location`.

### Environment

Aspire 13.5 candidate (`13.5.0-pr.17553`); observed live with `AddAzureStorage`, `storage-roles.module.bicep(2,7)`.

Contributor guide

Open the contributing guide

Research direction

Start in src/Aspire.Hosting.Azure/AzureResourceInfrastructure.cs, especially the unconditional location parameter, and trace AzureResourcePreparer.CreateGlobalRoleAssignmentsResource for the generated role module. Reproduce the warning with an Azure resource that creates role assignments, then determine how to preserve azd's location assumption while ensuring generated role modules no longer emit the no-unused-params warning.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, csharp
Domain
cloud, infrastructure
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.