Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AzureResourceManagerTemplateDeploymentV3 - Add .bicepparam support #19402

Merged

Conversation

Cadacious
Copy link
Contributor

Task name: AzureResourceManagerTemplateDeploymentV3

Description: Updated task to support .bicepparam file as input for csmParametersFile. Used much of the same logic and functionality that was originally used to include .bicep support with necessary changes.

Instead of accepting the default behavior of az bicep build-params --file filename.bicepparm to produce a filename.json file the --outfile parameter was used to add the .parameters.json extension.

This prevents the primary bicep file from being overwritten in the case it shares the same name as the param file. For example, az bicep build --file main.bicep and az bicep build-params --file main.bicepparam both produce a main.json file. Running both back to back in the same task will cause converted output of the .bicepparam file to overwrite the .bicep file converted output.

The resulting .parameters.json file is deposited into and referenced from the same directory as the .bicepparm file came from.

Documentation changes required: Yes. I have changes for that ready in my forked copy of the azure-devops-yaml-schema repository.

Added unit tests: Yes, unit tests were added.

Attached related issue: #19064 #18521

Checklist:

  • Task version was bumped - please check instruction how to do it
  • Checked that applied changes work as expected

@Cadacious
Copy link
Contributor Author

Couple of additional things i would like to note here:

  1. I was unsure if changes needed to be made in Tasks\AzureResourceManagerTemplateDeploymentV3 or _generated\AzureResourceManagerTemplateDeploymentV3_Node20 so i made the changes in both spots.
  2. I was able to get this to succeed via the unit testing but I did not have a way to run this updated code in a pipeline to ensure it succeeds in a live pipeline run.

@Cadacious Cadacious marked this pull request as ready for review December 22, 2023 19:27
@v-mohithgc
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@v-mohithgc
Copy link
Contributor

Hi @Cadacious , thanks for contributing on this task, I will check this PR and revert ASAP.

@v-mohithgc
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@Cadacious
Copy link
Contributor Author

Hi @Cadacious , thanks for contributing on this task, I will check this PR and revert ASAP.

I reviewed the pipeline failure and ran the BuildConfigGen tool as suggested. The exact command run was .\BuildConfigGen --task AzureResourceManagerTemplateDeploymentV3 --write-updates --configs Node20_229_2. I could not run the command without the configuration option as prompted in the pipeline error message.

If possible, please document proper usage of this tool on the public side of this repository so other community contributors are aware of all newly added required steps for contributing to these pipeline tasks.

@v-mohithgc
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@Cadacious
Copy link
Contributor Author

/azp run

Copy link

Commenter does not have sufficient privileges for PR 19402 in repo microsoft/azure-pipelines-tasks

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@SvenRelijveld1995
Copy link

I would love to see this finished! Thanks @Cadacious !

@Cadacious
Copy link
Contributor Author

@PhilipsonJoseph please review again and let me know if there is anything else needed to merge this in time for the upcoming task release window.

@PhilipsonJoseph
Copy link
Contributor

@Cadacious looks good to me i have approved your pull request

@v-mohithgc
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@v-mohithgc
Copy link
Contributor

Hi @Cadacious , thanks for this PR, I will procced to get it approved from relevant owners and will merge it soon.
Just to be sure that your code changes isn't breaking anything and serving the purpose, if possible, can you follow the below simple steps to test real pipeline scenario?

Local task test
Have code changes ready (checkout to this branch), navigate to task root path ie C:...\azure-pipelines-tasks
Note: tfx build works only on node 8 and 10, so make sure to use node 8/10 while testing the task

Step 1: run "npm i"

Step 2: Build:

node make.js build --task AzureResourceManagerTemplateDeploymentV3

Step 3: Install tfx:

npm install -g tfx-cli

Step 4: Login:

tfx login
Service URL : [your task test org url]
PAT :

Step 5: Upload:

tfx build tasks upload --task-path C:\AzurePipelineTask\azure-pipelines-tasks_build\Tasks\AzureResourceManagerTemplateDeploymentV3

New task version will be uploaded to your org, please test the changes by running the pipeline.

Step 6: Delete: // optional and can be done after all the testing is completed.

tfx build tasks delete --task-id { }

@Cadacious
Copy link
Contributor Author

This required a small change to the cleanup portion of the code to remove an extra . on the file extension that was accidentally inserted.

@v-mohithgc please see the below pipeline runs using the latest code for this task.

ARM template deployment task - validation with bicep param file

ARM Template deployment task - deployment with bicep param file

Also, I have never run across these instructions for testing changes to the in-box tasks like this in a pipeline run. These will prove invaluable to other community contributors to do final validations against their task contributions as was the case here. Please include these steps in the contribution readme for this repository.

@v-mohithgc
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@v-mohithgc
Copy link
Contributor

This required a small change to the cleanup portion of the code to remove an extra . on the file extension that was accidentally inserted.

@v-mohithgc please see the below pipeline runs using the latest code for this task.

ARM template deployment task - validation with bicep param file

ARM Template deployment task - deployment with bicep param file

Also, I have never run across these instructions for testing changes to the in-box tasks like this in a pipeline run. These will prove invaluable to other community contributors to do final validations against their task contributions as was the case here. Please include these steps in the contribution readme for this repository.

Hi @Cadacious ,
Thanks a bunch for your awesome contributions and testing! 🚀 Your efforts are making a real impact to this repo.
Also, got your feedback – noted and on it! Will work to implement ASAP.

@simonvane
Copy link

Awesome work @Cadacious! Thank you.

@v-mohithgc - do you know when this will be available in pipelines?

@v-mohithgc v-mohithgc merged commit 8bd8271 into microsoft:master Jan 31, 2024
8 checks passed
@v-mohithgc
Copy link
Contributor

Awesome work @Cadacious! Thank you.

@v-mohithgc - do you know when this will be available in pipelines?

version 235 should be shipped within the next 10-12 working days.

@sergiuser1
Copy link

sergiuser1 commented Feb 29, 2024

Awesome work @Cadacious! Thank you.
@v-mohithgc - do you know when this will be available in pipelines?

version 235 should be shipped within the next 10-12 working days.

Does the documentation have to be updated as well? It would be nice to have an example of how to use a .bicepparam file.

https://learn.microsoft.com/en-us/azure/azure-resource-manager/bicep/add-template-to-azure-pipelines?tabs=CLI#use-azure-resource-manager-template-deployment-task

@Cadacious
Copy link
Contributor Author

Does the documentation have to be updated as well? It would be nice to have an example of how to use a .bicepparam file.

https://learn.microsoft.com/en-us/azure/azure-resource-manager/bicep/add-template-to-azure-pipelines?tabs=CLI#use-azure-resource-manager-template-deployment-task

This has been updated in MicrosoftDocs/azure-docs#120346

@sergiuser1
Copy link

Great, thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants