bicep icon indicating copy to clipboard operation
bicep copied to clipboard

DevOps: CI/CD integration of BICEP

Open bveerendrakumar opened this issue 5 years ago • 8 comments

Is your feature request related to a problem? Please describe. This is related to integrating environment automation along with code like YAML CI/CD pipelines. YAML pipelines are part of code and they take care of CI/CD activities of DevOps. Similarly, if we could integrate BICEP scripts as part of code per component or whatever logical granularity, it would help a lot to achieve the desired state of the environment every time we deploy the code.

Describe the solution you'd like Integrate BICEP Compile and Deploy as Git hub action task Provide a feature in BICEP/ARM templates to verify the resource if exists or not. If exists then allow modifications, if not allow creation. The above ask helps to achieve repeatability and idempotency of the environment creation script.

I am not sure if there a way to achieve this already with the existing set of features. But would love to learn if there is one already.

bveerendrakumar avatar Dec 05 '20 16:12 bveerendrakumar

@alex-frankel , Please review and suggest.

bveerendrakumar avatar Dec 05 '20 16:12 bveerendrakumar

ب

mymo2202 avatar Dec 06 '20 20:12 mymo2202

@mymo2202 Looks like the comment is missing. Can you please check?

bveerendrakumar avatar Dec 07 '20 04:12 bveerendrakumar

Is this example the type of thing you are looking for? It is a pretty simple pipeline that does the following:

  • Install Bicep CLI
  • Run bicep build on main.bicep
  • Run what-if on the generated main.json
  • Deploy the template (this is commented out for the sake of my demo)

alex-frankel avatar Dec 07 '20 17:12 alex-frankel

Thanks @alex-frankel . I was thinking of a ready-made pipeline task for this. But we can live with the script also to some extent. The main challenge is what-if helps us to understand the deployment changes upfront but here is what I a looking for ...

In a CI/CD pipeline, I would like to integrate my bicep script, which should be repeatable. Meaning, if the resource doesn't exist it should create, if already exists it should always update the resource with settings in the bicep/ARM JSON file. This would enable a seamless integration of environment resources with CI/CD pipelines and eliminates different scripts to handle create/update scenarios. Not sure if this is possible already.

I see a feature request here.

https://feedback.azure.com/forums/281804-azure-resource-manager/suggestions/38217556-introduce-function-to-check-whether-a-resource-exi

bveerendrakumar avatar Dec 08 '20 04:12 bveerendrakumar

There is a community-managed task here that will take care of bicep build: https://github.com/marketplace/actions/bicep-build

Meaning, if the resource doesn't exist it should create, if already exists it should always update the resource with settings in the bicep/ARM JSON file.

I might be missing something because this is how Bicep/ARM templates work today. ARM doesn't distinguish between create or update, it'll just take whatever is in the template and get you to that state, regardless of what existed previously. Does that help?

The feature request you linked to is a slightly different issue. There are certain resources that behave poorly on an update and the only real way to deal with it is to check if the resource exists, so that if it does you can do a GET on the latest settings and merge them with the settings you want to update. However, this is the exception rather than the rule and is usually the result of a bad resource type API design.

alex-frankel avatar Dec 08 '20 16:12 alex-frankel

@alex-frankel , thanks for the reply. I tested and what you said is right. I got confused between the resource updates you mentioned and resource creation with the same name in other RG (this is expected to fail). As long as the template parameters are the same it's rerunnable except for the resources mentioned in that link. Got it.

Our organization is not allowing community extensions other than Microsoft published. Any plans to publish one from Microsoft?

bveerendrakumar avatar Dec 09 '20 18:12 bveerendrakumar

Yes, I think we will do one shortly after the 0.3 release

Going to close this issue as it looks like the main questions are resolved.

alex-frankel avatar Dec 09 '20 18:12 alex-frankel