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

Enable module cache location configuration with cli and config file #5026

Closed
SQLDBAWithABeard opened this issue Oct 29, 2021 · 2 comments
Closed
Labels
Needs: Author Feedback Awaiting feedback from the author of the issue

Comments

@SQLDBAWithABeard
Copy link

So this is related to #3283 and indeed is mentioned by @majastrz before the thread goes down a different path.

Goal

To be able to configure the location of the bicep cache via environment variable and/or configuration - via $ENV:BICEP_CACHE_LOCATION for example

Reasoning

The aim is to have a centralised container registry that holds versioned base modules but to be able to package a complete deployment package for use in a separate location (think air-gapped network, Azure Government Cloud, customers Azure Environment). We do not want to have to copy from one registry to another to achieve this.

As part of the build process for this package creation, bicep build would pull the modules from the registry into the cache. We would like to package them up for deployment and propose to copy the cache into the package.

When we need to deploy it would be easier to provide the cache location to the deployment instead of copying the files from the package into the cache location. This would also keep everything in one place and not risk rogue artifacts lying around complicating things.

We already have a version of this process using source controlled module files which requires the build process to use the correct version tag to create the package but using br:<acr>/file:tag would be significantly more elegant.

@SQLDBAWithABeard SQLDBAWithABeard added the enhancement New feature or request label Oct 29, 2021
@ghost ghost added the Needs: Triage 🔍 label Oct 29, 2021
@majastrz
Copy link
Member

majastrz commented Oct 29, 2021

This is already possible although might not be documented.

Can you try setting the BICEP_CACHE_DIRECTORY environment variable? By default it's set to ~/.bicep on Linux/Mac and %userprofile%\.bicep on Windows.

@majastrz majastrz added awaiting response and removed Needs: Triage 🔍 enhancement New feature or request labels Oct 29, 2021
@SQLDBAWithABeard
Copy link
Author

Ha - Thank you so much - this worked like a dream.

For those that want to know

$ENV:BICEP_CACHE_DIRECTORY = path to new cache

then

 bicep restore mywonderfulthing.bicep

will cache the files which can be packaged

then set the BICEP_CACHE_DIRECTORY var and deploy.

I literally deleted the modules from the ACR to see and it worked :-)
A little more written here. https://blog.robsewell.com/blog/bicep/iac/using-bicep-cache/

@ghost ghost locked as resolved and limited conversation to collaborators May 26, 2023
@StephenWeatherford StephenWeatherford added Needs: Author Feedback Awaiting feedback from the author of the issue and removed awaiting response labels Oct 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Needs: Author Feedback Awaiting feedback from the author of the issue
Projects
None yet
Development

No branches or pull requests

3 participants