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

Support building and deploying bicep templates #1767

Merged
merged 5 commits into from
Jul 7, 2021

Conversation

benbp
Copy link
Member

@benbp benbp commented Jun 30, 2021

This adds support to our common ARM deployment script to compile and deploy Azure bicep files.

Resolves #1712

@benbp benbp self-assigned this Jun 30, 2021
@benbp benbp added the Central-EngSys This issue is owned by the Engineering System team. label Jun 30, 2021
@benbp benbp force-pushed the benbp/test-resources-bicep branch from e1965bb to a23ef50 Compare June 30, 2021 21:49
@azure-sdk
Copy link
Collaborator

The following pipelines have been queued for testing:
java - template
java - template - tests
js - template
net - template
net - template - tests
python - template
python - template - tests
You can sign off on the approval gate to test the release stage of each pipeline.
See eng/common workflow

@azure-sdk
Copy link
Collaborator

The following pipelines have been queued for testing:
java - template
java - template - tests
js - template
net - template
net - template - tests
python - template
python - template - tests
You can sign off on the approval gate to test the release stage of each pipeline.
See eng/common workflow

@benbp benbp requested a review from weshaggard July 1, 2021 00:06
@benbp benbp force-pushed the benbp/test-resources-bicep branch from d3dcf8a to 7114bd9 Compare July 1, 2021 00:07
@azure-sdk
Copy link
Collaborator

The following pipelines have been queued for testing:
java - template
java - template - tests
js - template
net - template
net - template - tests
python - template
python - template - tests
You can sign off on the approval gate to test the release stage of each pipeline.
See eng/common workflow

Copy link
Member

@weshaggard weshaggard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few comments/suggestions but otherwise looks good once you finish your testing.

@check-enforcer-staging
Copy link

This pull request is protected by Check Enforcer.

What is Check Enforcer?

Check Enforcer helps ensure all pull requests are covered by at least one check-run (typically an Azure Pipeline). When all check-runs associated with this pull request pass then Check Enforcer itself will pass.

Why am I getting this message?

You are getting this message because Check Enforcer did not detect any check-runs being associated with this pull request within five minutes. This may indicate that your pull request is not covered by any pipelines and so Check Enforcer is correctly blocking the pull request being merged.

What should I do now?

If the check-enforcer check-run is not passing and all other check-runs associated with this PR are passing (excluding license-cla) then you could try telling Check Enforcer to evaluate your pull request again. You can do this by adding a comment to this pull request as follows:
/check-enforcer evaluate
Typically evaulation only takes a few seconds. If you know that your pull request is not covered by a pipeline and this is expected you can override Check Enforcer using the following command:
/check-enforcer override
Note that using the override command triggers alerts so that follow-up investigations can occur (PRs still need to be approved as normal).

@benbp benbp force-pushed the benbp/test-resources-bicep branch from 1db5bbf to db1ef44 Compare July 2, 2021 19:47
@benbp benbp requested a review from weshaggard July 2, 2021 19:47
@azure-sdk
Copy link
Collaborator

The following pipelines have been queued for testing:
java - template
java - template - tests
js - template
net - template
net - template - tests
python - template
python - template - tests
You can sign off on the approval gate to test the release stage of each pipeline.
See eng/common workflow

@azure-sdk
Copy link
Collaborator

The following pipelines have been queued for testing:
java - template
java - template - tests
js - template
net - template
net - template - tests
python - template
python - template - tests
You can sign off on the approval gate to test the release stage of each pipeline.
See eng/common workflow

@@ -119,6 +119,26 @@ function MergeHashes([hashtable] $source, [psvariable] $dest) {
}
}

function BuildBicepFile([System.IO.FileSystemInfo] $file) {
if (!(Get-Command bicep -ErrorAction Ignore)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is an appropriate check. According to https://docs.microsoft.com/en-us/azure/azure-resource-manager/bicep/deploy-powershell, Az 5.6.0 and newer support bicep. Why not just check if Az is that version or newer and let the cmdlets do their job?

if (!(Get-Module -FullyQualifiedName @{ModuleName='Az'; ModuleVersion='5.6.0'} -ListAvailable)) {
  throw 'No'
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This way, too, you don't introduce yet another dependency beyond the cmdlets.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We decided to call the tool directly because the rest of the deployment script depends on having a arm template json file for things like parsing parameters, etc, so we decided to call bicep build up front and keep the rest of the script the same.

Copy link
Member Author

@benbp benbp Jul 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding some context Wes' comment: while az bicep build is a supported command for the az cli, there is no equivalent bicep build command to compile to ARM templates in the Az cmdlet (not yet at least).

This check is really intended for local usage of New-TestResources.ps1 only, since the azure pipelines images include the Bicep command in the default image (except for MacOS, as I discovered today, so this is a separate problem that needs solving).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, for future context re arm template json: it's not just to keep the rest of the script the same, but to avoid having to write custom parsing for bicep file parameters.

@benbp
Copy link
Member Author

benbp commented Jul 7, 2021

Testing out an existing non-bicep live test: https://dev.azure.com/azure-sdk/internal/_build/results?buildId=987175&view=results

@benbp
Copy link
Member Author

benbp commented Jul 7, 2021

Tests ^^ are passing for normal usage. It looks like bicep was added to MacOS today (https://github.com/actions/virtual-environments/blob/e8381d7db3a011a744a9d76eebb6e044327cfdae/images/macos/provision/core/bicep.sh), so by the time anyone actually starts using bicep templates, I expect our MacOS agents to have caught up.

@ghost
Copy link

ghost commented Jul 7, 2021

Hello @azure-sdk!

Because this pull request has the auto-merge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@benbp
Copy link
Member Author

benbp commented Jul 7, 2021

/check-enforcer evaluate

@benbp benbp merged commit 9241b19 into Azure:main Jul 7, 2021
@benbp benbp deleted the benbp/test-resources-bicep branch July 7, 2021 19:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Central-EngSys This issue is owned by the Engineering System team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

New-TestResources.ps1 should automatically detect and use bicep files
4 participants