Use enums for polyglot role assignment in Azure resources#14656
Use enums for polyglot role assignment in Azure resources#14656sebastienros merged 5 commits intorelease/13.2from
Conversation
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 14656Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 14656" |
|
Can we expose an open ended "enum"? |
🎬 CLI E2E Test RecordingsThe following terminal recordings are available for commit
📹 Recordings uploaded automatically from CI run #22414466394 |
|
@davidfowl we had this discussion about the enum, we didn't really agreed on what's best at that time. My argument was that these values already existed in the different SDKs, but I looked again and I don't think the typescript sdk actually supports provisioning and exposes these. I am not sure anymore there would be duplication if we created an enum. We'd still need to map it to our C# SDK one. However how should it be open-ended? The only thing open we could try to also accept a role definition (id, rolename) from the guest app. But I think a direct mapping to the SDK we support is fine. |
|
We can make a new type in ATS to enable this though right? Much like we support for github models and foundry. |
There was a problem hiding this comment.
Pull request overview
This PR extends the Azure Hosting libraries’ polyglot (ATS) role-assignment surface by introducing ATS-compatible role enums and updating exported withRoleAssignments shims to use those enums (rather than role-name strings / Azure.Provisioning role types), with accompanying validation apphosts and a couple of new tests.
Changes:
- Added internal ATS-compatible role enums (
AzureStorageRole,AzureServiceBusRole,AzureKeyVaultRole) and updated exportedwithRoleAssignmentsoverloads to accept them. - Updated TypeScript polyglot validation apphosts to use the new enum-based APIs, and added a new Key Vault TS validation apphost scaffold.
- Added tests for null/empty role arrays (Storage + Key Vault).
Reviewed changes
Copilot reviewed 15 out of 16 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Aspire.Hosting.Azure.Tests/AzureStorageExtensionsTests.cs | Adds null/empty role-array regression coverage for Storage role assignment. |
| tests/Aspire.Hosting.Azure.Tests/AzureKeyVaultTests.cs | Adds a null-roles test for Key Vault role assignment (but currently targets the removed string overload). |
| src/Aspire.Hosting.Azure.Storage/AzureStorageRole.cs | Introduces ATS-compatible enum for Azure Storage roles. |
| src/Aspire.Hosting.Azure.Storage/AzureStorageExtensions.cs | Adds enum-based exported withRoleAssignments overload and updates ignore reason for the Azure.Provisioning overload. |
| src/Aspire.Hosting.Azure.ServiceBus/AzureServiceBusRole.cs | Introduces ATS-compatible enum for Service Bus roles. |
| src/Aspire.Hosting.Azure.ServiceBus/AzureServiceBusExtensions.cs | Switches exported polyglot role assignment to enum-based overload and removes string-role validation dictionary. |
| src/Aspire.Hosting.Azure.KeyVault/AzureKeyVaultRole.cs | Introduces ATS-compatible enum for Key Vault roles. |
| src/Aspire.Hosting.Azure.KeyVault/AzureKeyVaultResourceExtensions.cs | Switches exported polyglot role assignment to enum-based overload and removes string-role validation dictionary. |
| playground/polyglot/TypeScript/Aspire.Hosting.Azure.Storage/ValidationAppHost/apphost.ts | Updates TS validation apphost to use AzureStorageRole enum when calling withRoleAssignments. |
| playground/polyglot/TypeScript/Aspire.Hosting.Azure.ServiceBus/ValidationAppHost/apphost.ts | Updates TS validation apphost to use AzureServiceBusRole enum instead of role-name strings. |
| playground/polyglot/TypeScript/Aspire.Hosting.Azure.KeyVault/ValidationAppHost/tsconfig.json | Adds TS config for the new Key Vault validation apphost. |
| playground/polyglot/TypeScript/Aspire.Hosting.Azure.KeyVault/ValidationAppHost/package.json | Adds Node/TS package manifest for the new Key Vault validation apphost. |
| playground/polyglot/TypeScript/Aspire.Hosting.Azure.KeyVault/ValidationAppHost/package-lock.json | Adds lockfile for the new Key Vault validation apphost. |
| playground/polyglot/TypeScript/Aspire.Hosting.Azure.KeyVault/ValidationAppHost/apphost.ts | Adds Key Vault TS validation apphost that exercises exported members and enum-based role assignment. |
| playground/polyglot/TypeScript/Aspire.Hosting.Azure.KeyVault/ValidationAppHost/apphost.run.json | Adds run profile for the new Key Vault validation apphost. |
| playground/polyglot/TypeScript/Aspire.Hosting.Azure.KeyVault/ValidationAppHost/.aspire/settings.json | Adds Aspire polyglot settings pointing to the new Key Vault TS apphost. |
Files not reviewed (1)
- playground/polyglot/TypeScript/Aspire.Hosting.Azure.KeyVault/ValidationAppHost/package-lock.json: Language not supported
* Add role assignent for storage polyglot * Create enums for built in Azure roles * Improve testing
Complete and refactor role assignment exports for Azure resources