azure-sdk-for-net icon indicating copy to clipboard operation
azure-sdk-for-net copied to clipboard

Add Join function to BicepFunction for array-to-string operations

Open Copilot opened this issue 4 months ago • 1 comments

Description

Adds the Join Bicep function to combine array elements into a single string with a delimiter. This addresses the need to use join() in Bicep templates, as referenced in the Aspire codebase.

Changes:

  • Added Join(BicepList<string> array, BicepValue<string> delimiter) method to BicepFunction class
  • Returns BicepValue<string> representing the Bicep join() function call
  • Includes comprehensive test coverage with 9 tests covering literal arrays, variables, resource properties with TestResource, ToBicepExpression pattern, and edge cases
  • Tests use C# raw string literals (multi-line strings) for better readability
  • Tests follow the same pattern as existing tests by using TestResource class to demonstrate resource property usage
  • Updated API listings for net8.0, net10.0, and netstandard2.0 with the new Join method signature
  • Updated CHANGELOG.md with feature description

Usage:

// Literal array
var tags = new BicepList<string> { "Environment", "Project", "Owner" };
var result = BicepFunction.Join(tags, ",");
// Compiles to: join(['Environment', 'Project', 'Owner'], ',')

// From resource property
var resource = new TestResource("testResource");
var joined = BicepFunction.Join(resource.List, "-");
// Compiles to: join(testResource.list, '-')

// Using ToBicepExpression pattern with resource property
var resource = new TestResource("testResource");
var result = BicepFunction.Join(resource.List, ";");
// Compiles to: join(testResource.list, ';')

This checklist is used to make sure that common guidelines for a pull request are followed.

General Guidelines

  • [x] Title of the pull request is clear and informative.
  • [x] There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.

Testing Guidelines

  • [x] Pull request includes test coverage for the included changes.

SDK Generation Guidelines

  • [ ] If an SDK is being regenerated based on a new swagger spec, a link to the pull request containing these swagger spec changes has been included above.
  • [ ] The generate.cmd file for the SDK has been updated with the version of AutoRest, as well as the commitid of your swagger spec or link to the swagger spec, used to generate the code.
  • [ ] The *.csproj and AssemblyInfo.cs files have been updated with the new version of the SDK.
Original prompt

This section details on the original issue you should resolve

<issue_title>Add more bicep string functions to BicepFunction</issue_title> <issue_description>https://learn.microsoft.com/en-us/azure/azure-resource-manager/bicep/bicep-functions-string

We're using join here:

https://github.com/dotnet/aspire/blob/16dbd2fa451445567339a100fbfb4870d3c23efd/src/Aspire.Hosting.Azure.AppService/AzureAppServiceWebsiteContext.cs#L276

It would be great to add the list of functions here.</issue_description>

<agent_instructions>Now we just limited the added API to join right now.</agent_instructions>

Comments on the Issue (you are @copilot in this section)

  • Fixes Azure/azure-sdk-for-net#50682

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot avatar Dec 09 '25 07:12 Copilot

@copilot please resolve the comment. Please run <RepoRoot>/eng/scripts/Export-API.ps1 provisioning to refresh the API, and update changelog file.

Completed:

  • Ran eng/scripts/Export-API.ps1 provisioning to refresh API listings
  • Updated CHANGELOG.md with feature description

Changes in commit c06b0a9.

Copilot avatar Dec 09 '25 09:12 Copilot