Keayoub / AzureDevBoxDevEnvironments

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Dev Box and Dev Environments

image

Prerequisites

To Run Locally

NOTE: Your Azure Account must have Microsoft.Authorization/roleAssignments/write permissions, such as User Access Administrator or Owner.

To Run in GitHub Codespaces or VS Code Remote Containers

You can run this repo virtually by using GitHub Codespaces or VS Code Remote Containers. Click on one of the buttons below to open this repo in one of those options.

Open in GitHub Codespaces Open in Remote - Containers

Installation using Azd deployment

Project Initialization

  1. Create a new folder your_folder_name
  2. git clone https://github.com/Keayoub/AzureDevBoxDevEnvironments.git your_folder_name
  3. switch to your your_folder_name in the terminal
  4. Run azd auth login

Starting from scratch

Execute the following command, if you don't have any pre-existing Azure services and want to start from a fresh deployment.

  1. Set variables values for your first run :
azd env set AZURE_ENV_NAME="YOUR ENVIRONNEMENT NAME"
azd env set AZURE_IMAGE_BUILDER_IDENTITY="IMAGE BUILDER IDENTITY NAME"
azd env set AZURE_LOCATION="LOCATION"
azd env set AZURE_RESOURCE_GROUP="YOUR RESOURCE GROUP NAME"
azd env set AZURE_SUBSCRIPTION_ID="************************************"
azd env set keyVaultPatSecretValue="***********************************"
  1. Change the property deployVnet to true if you want to create a new VNET
 "deployVnet": {
    "value": true
 },
  1. If you want to deploy custom Image Template with your DevCenter Change the property deployCustomImage to true otherwise keep it as false
 "deployCustomImage": {
    "value": true
 },
  1. Run azd up - This will provision Azure resources and deploy this sample to those resources.

Using existing resources

  1. Run azd env set AZURE_SUBSCRIPTION_ID {Name of existing OpenAI service}
  2. Run azd env set AZURE_RESOURCE_GROUP {Name of existing resource group that provisioned to}
  3. Run azd env set AZURE_DEVBOX_NAME {Name of existing DevBox deployment}
  4. Run azd env set AZURE_DEVBOX_VNET_NAME {Name of existing VNET deployment}. You need also to change in your main.parameters.json value of deployVnet to false
  5. Run azd env set keyVaultPatSecretValue {Value of your github PAT_TOKEN Providing a PAT, which will create the keyvault to store it}
  6. Run azd up

NOTE: You can also use existing Search and Storage Accounts. See ./infra/main.parameters.json for list of environment variables to pass to azd env set to configure those existing resources.

Deploying again

If you've only changed the backend/frontend code in the app folder, then you don't need to re-provision the Azure resources. You can just run:

azd deploy

If you've changed the infrastructure files (infra folder or azure.yaml), then you'll need to re-provision the Azure resources. You can do that by running:

azd up

AZ Deployment examples

if you want to use Az or powershell deployment your can use the follow commands (using Az PowerShell)

Providing a PAT, which will create the keyvault to store it

$ghPATToken = ConvertTo-SecureString -String "PAT_TOKEN" -AsPlainText -Force
New-AzDeployment -Name DevBox -Location EastUS2 -TemplateFile .\src\main.bicep -TemplateParameterFile .\src\main.parameters.jsonc -keyVaultPatSecretValue $ghPATToken -Verbose

Deploy using pipeline

  1. Open the Bicep parameters file, located under \src\main.parameters.jsonc

  2. Configure the following parameters

    Variable Type Required Description
    environmentName Text Yes Name of the environment which is used to generate a short unique hash used in all resources
    Location Text Yes Primary location for all resources, determine availbility in desired region
    resourceGroupName Text Yes The resource group name where the resources will be deployed
    deployVnet Boolean Yes True for initial deployment of the virtual network. If it's already created, this should be false
    devboxRbac GUID/Text Yes Provide the principalId and roleType (User or Group)
  3. Open the YAML pipeline located under .pipelines\devbox-deply.yml and modify the parameters.

  4. As indicated, ensure the Service connection has 'Microsoft.Authorization/roleAssignments/write' permissions.

About


Languages

Language:Bicep 52.9%Language:PowerShell 47.1%