This commit is contained in:
Anthony Martin 2022-09-13 20:44:52 -04:00 коммит произвёл GitHub
Родитель 78d5170232
Коммит 4e163b791c
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
5 изменённых файлов: 49 добавлений и 81 удалений

Просмотреть файл

@ -1,33 +1,5 @@
# Start from the dotnet base image to allow easy install of Powershell and ensure common tools are available for things like the bicep language server.
FROM mcr.microsoft.com/dotnet/sdk:5.0
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.238.1/containers/ubuntu/.devcontainer/base.Dockerfile
# Configure the release version of Bicep you'd like to use
ARG BICEP_VERSION=latest
# Pinned to ensure compatability with dotnet version installed in container
ARG POWSERSHELL_VERSION=7.1.1
# Install Azure CLI
RUN curl -sL https://aka.ms/InstallAzureCLIDeb | bash
# Install common tooling
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends curl build-essential
# Install Azure Powershell
ENV PATH="$PATH:/root/.dotnet/tools"
RUN \
dotnet tool install -g powershell --version $POWSERSHELL_VERSION \
&& pwsh -c "Install-Module -Name Az -AllowClobber -Scope AllUsers -Force"
# Install Bicep
RUN \
# Fetch the latest Bicep CLI binary
curl -Lo bicep https://github.com/Azure/bicep/releases/${BICEP_VERSION}/download/bicep-linux-x64 \
# Mark it as executable
&& chmod +x ./bicep \
# Add bicep to your PATH (requires admin)
&& mv ./bicep /usr/local/bin/bicep \
# Verify you can now access the 'bicep' command
&& bicep --help \
# Download the bicep vscode extension for installation
&& curl -Lo /tmp/vscode-bicep.vsix https://github.com/Azure/bicep/releases/${BICEP_VERSION}/download/vscode-bicep.vsix
# [Choice] Ubuntu version (use ubuntu-22.04 or ubuntu-18.04 on local arm64/Apple Silicon): ubuntu-22.04, ubuntu-20.04, ubuntu-18.04
ARG VARIANT="jammy"
FROM mcr.microsoft.com/vscode/devcontainers/base:0-${VARIANT}

Просмотреть файл

@ -1,26 +1,17 @@
{
"name": "Bicep Authoring devcontainer",
"dockerFile": "Dockerfile",
"forwardPorts": [ 7071 ],
// Set *default* container specific settings.json values on container create.
"settings": {
"terminal.integrated.shell.linux": "/usr/bin/pwsh"
},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"/tmp/vscode-bicep.vsix",
"ms-vscode.powershell",
"msazurermtools.azurerm-vscode-tools"
],
"mounts": [
// This mount ensures that the Azure Powershell credentials aren't lost between
// runs of the container.
"type=volume,source=bicepazpowershellcreds,target=/root/.Azure",
// same thing for the Azure CLI
"type=volume,source=bicepazureclicreds,target=/root/.azure",
]
}
"build": {
"dockerfile": "Dockerfile",
"args": {
"VARIANT": "ubuntu-22.04"
}
},
"extensions": [
"ms-azuretools.vscode-azureresourcegroups",
"ms-azuretools.vscode-bicep",
"editorconfig.editorconfig"
],
"remoteUser": "vscode",
"features": {
"azure-cli": "latest"
}
}

1
.gitignore поставляемый
Просмотреть файл

@ -1 +0,0 @@
main.json

Просмотреть файл

@ -3,29 +3,35 @@
This is a simple devcontainer which can be used with CodeSpaces or VSCode Remote to get all the tooling needed to start authoring bicep.
## Quick Start: VSCode Remote
1. Clone the repository.
1. Configuration for the development environment by installing VSCode and the Devcontainers extension. [Quick start docs here](https://code.visualstudio.com/docs/remote/containers-tutorial).
1. Open the folder in VSCode
devcontain1. [`CTRL+SHIFT+P` then type `Reopen in container`](https://code.visualstudio.com/docs/remote/containers#_getting-started) to open the devcontainer in VSCode.
1. Configure the development environment by installing VSCode and the "Remote - Containers" extension. [Quick start docs here](https://code.visualstudio.com/docs/remote/containers-tutorial).
1. Open the repository in VSCode
1. [`CTRL+SHIFT+P` then type `Reopen in container`](https://code.visualstudio.com/docs/remote/containers#_getting-started) to open the devcontainer in VSCode.
1. [Open a terminal in VSCode with `CTRL+SHIFT+P` -> `Terminal: Create new integrated terminal`](https://code.visualstudio.com/docs/remote/containers#_opening-a-terminal). We'll use this to run Bicep commands.
1. [Run `az login`](https://docs.microsoft.com/en-us/cli/azure/authenticate-azure-cli) from the VSCode terminal to connect to your Azure account.
1. Run `bicep build main.bicep` this will generate `main.json` which is the ARM template ready to be deployed.
1. Run the following to create a resource group and deploy the template to it.
```
az group create -n my-rg -l eastus
az deployment group create -f ./main.json -g my-rg
```
1. Run the following to create a resource group and deploy your Bicep file to it.
```sh
az group create -n my-rg -l eastus
az deployment group create -f ./main.bicep -g my-rg
```
1. Open [main.bicep](./main.bicep) in to modify the resources you want to deploy, and re-run the `az deployment group` command to re-deploy the resources.
## Quick Start: Codespaces
1. Open this repository in [GitHub Codespaces](https://github.com/features/codespaces).
1. Open a terminal in VSCode with `CTRL+J`. We'll use this to run Bicep commands.
1. [Run `az login`](https://docs.microsoft.com/en-us/cli/azure/authenticate-azure-cli) from the VSCode terminal to connect to your Azure account.
1. Run the following to create a resource group and deploy your Bicep file to it.
```sh
az group create -n my-rg -l eastus
az deployment group create -f ./main.bicep -g my-rg
```
1. Open [main.bicep](./main.bicep) in your Codespaces window to modify the resources you want to deploy, and re-run the `az deployment group` command to re-deploy the resources.
## Next Steps
Review [the docs here](https://github.com/Azure/bicep) to build out more advanced scenarios.
Review [the Bicep documentation](https://docs.microsoft.com/en-us/azure/azure-resource-manager/bicep/overview) to build out more advanced scenarios.
## Configuration
To target a specific release of Bicep update the `./devcontainer/Dockerfile` argument `ARG BICEP_VERSION=latest` to the required version.
# Contributing
## Contributing
This project welcomes contributions and suggestions. Most contributions require you to agree to a
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us

Просмотреть файл

@ -1,8 +1,8 @@
resource stg 'Microsoft.Storage/storageAccounts@2019-06-01' = {
name: uniqueString(resourceGroup().id)
location: 'eastus'
kind: 'Storage'
sku: {
name: 'Standard_LRS'
}
}
name: uniqueString(resourceGroup().id)
location: 'eastus'
kind: 'Storage'
sku: {
name: 'Standard_LRS'
}
}