Skip to content

anthony-c-martin/bicep-local-providers

Repository files navigation

Local-only Bicep

This document explains how to set up the experimental local-only deployment support for 3rd party extensions, without a dependency on Azure.

Here's an example of deploying to a local kubernetes cluster, logging, and executing a bash script via terminal:

image

Here's an example of using VSCode to dpeloy to a local kubernetes cluster:

Screen.Recording.2024-01-08.at.11.40.02.AM.mov

Running Samples

  • Copy the full samples folder locally. You can use this tool to download it as a zip file.
  • For testing with the Kubernetes extension, you will need access to a cluster configured in your kubeconfig file. If you have Docker installed, this can be obtained by Enabling Kubernetes Support.

Via CLI

Replace <path_to_bicepparam> with the path to the .bicepparam file you wish to deploy.

~/.azure/bin/bicep local-deploy <path_to_bicepparam>

Via VSCode

Open the Deployment Pane for a .bicepparam file you wish to deploy, and press the "Deploy" button.

Utils Samples

Bash/PowerShell script execution (samples/utils/script.bicepparam)

Execute a bash or powershell script as part of a local deployment.

"Wait" functionality (samples/utils/wait.bicepparam)

Introduce a sleep for a given number of milliseconds in your deployment.

Logging functionality (samples/utils/log.bicepparam)

Write a log to console during your deployment to help debug.

Assertion functionality (samples/utils/assert.bicepparam)

Fail the deployment if a certain condition is false.

Kubernetes Samples

This will run the Voting App Sample locally.

After deploying, test it out by navigating to http://localhost in a browser.

Cleanup:

kubectl delete deployment azure-vote-back
kubectl delete deployment azure-vote-front
kubectl delete service azure-vote-back
kubectl delete service azure-vote-front

This will run the echo-server service locally.

Test it out by submitting a request:

curl -I localhost:8080

Cleanup:

kubectl delete deployment echo-server 
kubectl delete service echo-server

GitHub Samples

Fetch Repo information (samples/github/repo.bicepparam)

Fetches a repo + contributor from GitHub.

Contributing new extensions or types

I'm happy to take contributions to this repo to extend experimental extensions or add new ones. Please reach out to me via the issue tracker for more information.

Caveats

  • There is currently no support for deploying Azure resources. Theoretically there's no reason why this can't work, I just haven't had the time to build it.

  • Extension binary packages are not currently signed. If you see the following error on Mac, you may need to manually sign the extension package:

    Failed to launch provider: Failed to connect to provider /Users/ant/.bicep/br/biceplocaldeploy.azurecr.io/extension$utils/0.1.1$/provider.bin

    To work around it, run the following in a terminal window, using the path from the error message:

    codesign -s - '/Users/ant/.bicep/br/biceplocaldeploy.azurecr.io/extensions$utils/0.1.1$/provider.bin'

About

Repo to manage local Bicep providers

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published