MoimHossain / bicep-local-providers

Repo to manage local Bicep providers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Local-only Bicep

This document explains how to set up the experimental local-only deployment support for 3rd party extensibility providers, 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

Installing

Mac/Linux

# install the CLI to ~/.azure/bin/bicep
bash <(curl -Ls https://aka.ms/bicep/nightly-cli.sh) --branch localdeploy
# install the VSCode Extension
bash <(curl -Ls https://aka.ms/bicep/nightly-vsix.sh) --branch localdeploy

Windows

# install the CLI to ~/.azure/bin/bicep
iex "& { $(irm https://aka.ms/bicep/nightly-cli.ps1) } -Branch localdeploy"
# install the VSCode Extension
iex "& { $(irm https://aka.ms/bicep/nightly-vsix.ps1) } -Branch localdeploy"

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 provider, 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 providers or types

I'm happy to take contributions to this repo to extend experimental providers 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.

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

    Failed to launch provider: Failed to connect to provider /Users/ant/.bicep/br/biceplocaldeploy.azurecr.io/providers$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/providers$utils/0.1.1$/provider.bin'

About

Repo to manage local Bicep providers

License:MIT License


Languages

Language:C# 89.6%Language:Shell 9.1%Language:Bicep 1.3%