From c15fc7b454ef171a6258d0bf0b737568526fb296 Mon Sep 17 00:00:00 2001 From: Anthony Shaw Date: Sun, 5 May 2024 14:26:26 +1000 Subject: [PATCH] Cruft Update (force) --- .cruft.json | 64 +++++------ .github/workflows/test.yml | 50 --------- .../core/database/cosmos/cosmos-account.bicep | 1 + .../azure-front-door-cdn-profile.bicep | 101 ++++++++++++++++++ infra/main.bicep | 22 ++-- lab/02-examining-project.md | 42 -------- lab/03-testing.md | 79 -------------- lab/04-deploying-locally.md | 28 ----- lab/05-deploying-to-azure.md | 82 -------------- lab/06-teardown.md | 17 --- lab/README.md | 48 --------- lab/bonus-07-use-azd-template.md | 35 ------ lab/fasttrack.md | 71 ------------ 13 files changed, 146 insertions(+), 494 deletions(-) delete mode 100644 .github/workflows/test.yml create mode 100644 infra/core/network/azure-front-door-cdn-profile.bicep delete mode 100644 lab/02-examining-project.md delete mode 100644 lab/03-testing.md delete mode 100644 lab/04-deploying-locally.md delete mode 100644 lab/05-deploying-to-azure.md delete mode 100644 lab/06-teardown.md delete mode 100644 lab/README.md delete mode 100644 lab/bonus-07-use-azd-template.md delete mode 100644 lab/fasttrack.md diff --git a/.cruft.json b/.cruft.json index 0a0a345..8cd923b 100644 --- a/.cruft.json +++ b/.cruft.json @@ -1,33 +1,33 @@ { - "template": "https://github.com/Azure-Samples/Azure-Python-Standardization-Template-Generator", - "commit": "c75367846861bc3563aefae0831a06d715b75286", - "checkout": null, - "context": { - "cookiecutter": { - "project_name": "Relecloud", - "python_version": "3.12", - "project_backend": "django", - "db_resource": "postgres-flexible", - "project_host": "aca", - "web_port": "8000", - "__repo_name": "Relecloud-django-postgres-flexible-aca", - "__src_folder_name": "relecloud_django_postgres_flexible_aca", - "__project_short_description": "Create a relecloud demo application with django and postgres-flexible", - "_copy_without_render": [ - ".github/workflows/azure-dev.yml", - ".github/workflows/cruft.yml", - ".github/workflows/devcontainer-ci.yml", - ".github/workflows/format.yml" - ], - "_extensions": [ - "extensions.GetUrlForBackend" - ], - "_jinja2_env_vars": { - "lstrip_blocks": true, - "trim_blocks": true - }, - "_template": "https://github.com/Azure-Samples/Azure-Python-Standardization-Template-Generator" - } - }, - "directory": null -} + "template": "https://github.com/Azure-Samples/Azure-Python-Standardization-Template-Generator", + "commit": "3300bfb387c4ce2cbd9ae2c48e77fc069f3d977e", + "checkout": null, + "context": { + "cookiecutter": { + "project_name": "Relecloud", + "python_version": "3.12", + "project_backend": "django", + "db_resource": "postgres-flexible", + "project_host": "aca", + "web_port": "8000", + "__repo_name": "Relecloud-django-postgres-flexible-aca", + "__src_folder_name": "azure-django-postgres-flexible-aca", + "__project_short_description": "Create a relecloud demo application with django and postgres-flexible", + "_copy_without_render": [ + ".github/workflows/azure-dev.yml", + ".github/workflows/cruft.yml", + ".github/workflows/devcontainer-ci.yml", + ".github/workflows/format.yml" + ], + "_extensions": [ + "extensions.GetUrlForBackend" + ], + "_jinja2_env_vars": { + "lstrip_blocks": true, + "trim_blocks": true + }, + "_template": "https://github.com/Azure-Samples/Azure-Python-Standardization-Template-Generator" + } + }, + "directory": null +} \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index bb4a3e0..0000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,50 +0,0 @@ -name: Run Python E2E tests - -on: - push: - branches: [ main ] - pull_request: - branches: [ main ] - -jobs: - test_package: - - name: Test ${{ matrix.os }} Python ${{ matrix.python_version }} - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: ["ubuntu-20.04"] - python_version: ["3.8", "3.9", "3.10", "3.11", "3.12"] - services: - db: - image: postgres:14 - env: - POSTGRES_PASSWORD: postgres - ports: - - 5432:5432 - # needed because the postgres container does not provide a healthcheck - options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 - steps: - - uses: actions/checkout@v3 - - name: Setup python - uses: actions/setup-python@v2 - with: - - python-version: ${{ matrix.python_version }} - architecture: x64 - - name: Install dependencies - run: | - python3 -m pip install --upgrade pip - python3 -m pip install -r requirements-dev.txt - playwright install chromium --with-deps - - name: Seed data and run Pytest tests - run: | - python3 src/manage.py migrate - python3 src/manage.py loaddata src/seed_data.json - python3 -m pytest - env: - POSTGRES_HOST: localhost - POSTGRES_USERNAME: postgres - POSTGRES_PASSWORD: postgres - POSTGRES_DATABASE: postgres \ No newline at end of file diff --git a/infra/core/database/cosmos/cosmos-account.bicep b/infra/core/database/cosmos/cosmos-account.bicep index 6f8747f..741a862 100644 --- a/infra/core/database/cosmos/cosmos-account.bicep +++ b/infra/core/database/cosmos/cosmos-account.bicep @@ -3,6 +3,7 @@ param name string param location string = resourceGroup().location param tags object = {} +@secure() param connectionStringKey string = 'AZURE-COSMOS-CONNECTION-STRING' param keyVaultName string diff --git a/infra/core/network/azure-front-door-cdn-profile.bicep b/infra/core/network/azure-front-door-cdn-profile.bicep new file mode 100644 index 0000000..691577d --- /dev/null +++ b/infra/core/network/azure-front-door-cdn-profile.bicep @@ -0,0 +1,101 @@ +metadata description = 'Creates an Azure Frontdoor CDN profile in front of a storage domain.' + +param name string +param origin string +param tags object = {} +param allowHttp bool = false +param httpsRedirect bool = true +param defaultRouteName string = 'default-route' +param defaultOriginGroupName string = 'default-origin-group' +param defaultOriginName string = 'default-origin' + +@allowed(['Enabled', 'Disabled']) +param sessionAffinityState string = 'Disabled' + +var supportedProtocols = allowHttp ? [ + 'Http' + 'Https' +] : [ + 'Https' +] + +@allowed(['Standard_AzureFrontDoor', 'Premium_AzureFrontDoor']) +param sku string = 'Standard_AzureFrontDoor' + +param originResponseTimeoutSeconds int = 60 + +resource cdnProfile 'Microsoft.Cdn/profiles@2023-07-01-preview' = { + name: name + location: 'Global' + tags: tags + sku: { + name: sku + } + properties: { + originResponseTimeoutSeconds: originResponseTimeoutSeconds + } +} + +resource originGroups 'Microsoft.Cdn/profiles/origingroups@2022-11-01-preview' = { + name: defaultOriginGroupName + parent: cdnProfile + properties: { + loadBalancingSettings: { + sampleSize: 4 + successfulSamplesRequired: 3 + additionalLatencyInMilliseconds: 50 + } + healthProbeSettings: { + probePath: '/' + probeRequestType: 'HEAD' + probeProtocol: allowHttp ? 'Http' : 'Https' + probeIntervalInSeconds: 100 + } + sessionAffinityState: sessionAffinityState + } + + resource origins 'origins@2022-11-01-preview' = { + name: defaultOriginName + properties: { + hostName: origin + httpPort: 80 + httpsPort: 443 + originHostHeader: origin + priority: 1 + weight: 1000 + enabledState: 'Enabled' + enforceCertificateNameCheck: true + } + } +} + +resource afdEndpoints 'Microsoft.Cdn/profiles/afdEndpoints@2023-05-01' = { + parent: cdnProfile + name: name + location: 'Global' + properties: { + enabledState: 'Enabled' + } + + resource routes 'routes@2022-11-01-preview' = { + name: defaultRouteName + properties: { + customDomains: [] + originGroup: { + id: originGroups.id + } + ruleSets: [] + supportedProtocols: supportedProtocols + patternsToMatch: [ + '/*' + ] + forwardingProtocol: 'MatchRequest' + linkToDefaultDomain: 'Enabled' + httpsRedirect: httpsRedirect ? 'Enabled' : 'Disabled' + enabledState: 'Enabled' + } + } +} + +output cdnProfileId string = cdnProfile.id +output endpointHostname string = afdEndpoints.properties.hostName diff --git a/infra/main.bicep b/infra/main.bicep index 701f488..09e4d08 100644 --- a/infra/main.bicep +++ b/infra/main.bicep @@ -88,7 +88,7 @@ module web 'web.bicep' = { name: 'web' scope: resourceGroup params: { - name: replace('${take(prefix, 19)}-ca', '--', '-') + name: replace('${take(prefix,19)}-ca', '--', '-') location: location tags: tags applicationInsightsName: monitoring.outputs.applicationInsightsName @@ -116,15 +116,17 @@ var secrets = [ ] @batchSize(1) -module keyVaultSecrets './core/security/keyvault-secret.bicep' = [for secret in secrets: { - name: 'keyvault-secret-${secret.name}' - scope: resourceGroup - params: { - keyVaultName: keyVault.outputs.name - name: secret.name - secretValue: secret.value +module keyVaultSecrets './core/security/keyvault-secret.bicep' = [ + for secret in secrets: { + name: 'keyvault-secret-${secret.name}' + scope: resourceGroup + params: { + keyVaultName: keyVault.outputs.name + name: secret.name + secretValue: secret.value + } } -}] +] output AZURE_LOCATION string = location output AZURE_CONTAINER_ENVIRONMENT_NAME string = containerApps.outputs.environmentName @@ -138,4 +140,4 @@ output AZURE_KEY_VAULT_ENDPOINT string = keyVault.outputs.endpoint output AZURE_KEY_VAULT_NAME string = keyVault.outputs.name output APPLICATIONINSIGHTS_NAME string = monitoring.outputs.applicationInsightsName -output BACKEND_URI string = web.outputs.uri \ No newline at end of file +output BACKEND_URI string = web.outputs.uri diff --git a/lab/02-examining-project.md b/lab/02-examining-project.md deleted file mode 100644 index 93fa28e..0000000 --- a/lab/02-examining-project.md +++ /dev/null @@ -1,42 +0,0 @@ -[01 Getting Started](./README.md) | 02 Examining the Project | [03 Testing](./03-testing.md) | [04 Deploying Locally](./04-deploying-locally.md) | [05 Deploying to Azure](./05-deploying-to-azure.md) | [06 Teardown](./06-teardown.md) - -# Examining the Project - -Before we deploy our application, let's take a look at the project. - -## Project Structure - -```shell -. -├── .devcontainer -│ ├── Dockerfile_dev -│ ├── docker-compose_dev.yml -├── demo-code -│ ├── Dockerfile -│ ├── manage.py -│ ├── project -│ ├── relecloud -├── docker-compose.yml -├── infra -``` - -The code we will deploy exists in the `demo-code` folder. This is a [Django](https://djangoproject.com) project that is the base for a space tourism company called "Relecloud". Users can visit the site to learn about the tours taken around the solar system. - -## Creating our Environment using Docker/Docker Compose - -You may notice we have 2 Docker Compose files and 2 Dockerfiles. [docker-compose.yml](./../docker-compose.yml) serves as the base configuration for all of the development environments. This ensures that your deployment environment is as close to your development environment as possible. - - [.devcontainer/docker-compose_dev.yml](./../../.devcontainer_fastapi/docker-compose_dev.yml) and [.devcontainer/Dockerfile_dev](./../../.devcontainer_fastapi/Dockerfile_dev) are used to configure the development environment when using [Dev Containers](https://code.visualstudio.com/docs/remote/containers) or [Codespaces](https://codespaces.github.com). `Dockerfile_dev` provides configuration changes specific to local testing to ensure that our testing database is configured correctly, while remaining separate from production. - -> **:book: Learn More** -> -> Learn more about [creating Dev Containers](https://containers.dev) - -## Infrastructure as Code and Azure Developer CLI (AZD) - -Finally, [demo-code/Dockerfile](./../demo-code/Dockerfile) is used to build the image that will be deployed to Azure using the Azure Developer CLI (AZD). We also have an [infra](./../infra) folder that contains the [Bicep](https://learn.microsoft.com/en-us/azure/azure-resource-manager/bicep/overview) templates used to deploy the infrastructure to Azure using the [Azure Developer CLI](https://learn.microsoft.com/en-us/azure/developer/azure-developer-cli/overview). We'll take a look at these files later in the lab, but this is key to being able to deploy our code rapidly and reliably. - -We will talk more about AZD later in the lab. -## Next - -Proceed to [03 Testing](./03-testing.md) diff --git a/lab/03-testing.md b/lab/03-testing.md deleted file mode 100644 index 377de8c..0000000 --- a/lab/03-testing.md +++ /dev/null @@ -1,79 +0,0 @@ -[01 Getting Started](./README.md) | [02 Examining the Project](./02-examining-project.md) | 03 Testing | [04 Deploying Locally](./04-deploying-locally.md) | [05 Deploying to Azure](./05-deploying-to-azure.md) | [06 Teardown](./06-teardown.md) - -# Testing - -We need to test that our Django application works as expected. We have provided some tests to ensure that you can visit all of the urls and that the data is being returned as expected. - -## Installing the prerequisites - -The Dev Container already has the production requirements for the Django app installed, -but it doesn't have the development requirements yet: the linting and testing packages. - -Install the development requirements via pip: - -> **:computer: Try It!** ->```shell -> python -m pip install -r requirements-dev.txt -> ``` - -## Testing via Django tests - -The first set of tests we'll run are the Django tests. These tests are run inside of the container and are a great way to ensure that your application is working as expected. Django does a fantastic job of setup and teardown of test resources. - -Navigate to the `demo-code` folder and run the `test` command: - -> **:computer: Try It!** -> ```shell -> cd demo-code -> python manage.py collectstatic -> python manage.py test relecloud.tests -> ``` - -https://user-images.githubusercontent.com/8632637/229249044-7c8b65d1-3fdc-46a1-9c72-09519452500d.mp4 - - -## Testing the frontend of the application with Playwright - -There are some things you can't test without loading the website. For that we'll use [Playwright](https://playwright.dev/), a browser automation library that allows us to run tests against our website. We've included tests that will navigate across multiple pages of the website, similar to how a user would. - -First, install Playwright and its dependencies, the headless browser builds. ⚠️ If you're on an M1 Mac, it's not possible to run the browsers from inside the Dev Container. In that case, either use GitHub Codespaces or a local virtual environment. - -> **:computer: Try It** -> ```shell -> playwright install --with-deps -> ``` - -Playwright tests can be written using either the `pytest` framework or the `unittest` framework. The tests we've included use the `unittest` framework by extending Django's `StaticLiveServerTestCase`. - -Navigate to the `demo-code` folder and run the `test` command: - -> **:computer: Try It** -> ```shell -> cd demo-code -> python manage.py collectstatic -> python manage.py test relecloud.playwright -> ``` - -> **📖 Learn More** -> -> Check out these Playwright resources for more information -> -> - [Playwright](https://playwright.dev/) -> - [Playwright Python](https://playwright.dev/python/docs/intro/) -> - [Pytest Playwright](https://github.com/microsoft/playwright-pytest) - - -## Testing via GitHub Actions - -This is great, however we may forget to run these tests every time we make a change. We can use GitHub Actions to run these tests for us. - -We've included a [GitHub Action](./../.github/workflows/test.yml) that will run our tests for us inside of a containerized environment. - -> **:mag: Explore** -> You can use the GitHub Actions Extension in VS Code (included in your Dev Container) to view the GitHub Action that is running our tests. - -![The GitHub Actions Pane in VS Code](./../assets/view%20Actions.png) - -## Next - -Proceed to [04 Deploying Locally](./04-deploying-locally.md) diff --git a/lab/04-deploying-locally.md b/lab/04-deploying-locally.md deleted file mode 100644 index 1e16df5..0000000 --- a/lab/04-deploying-locally.md +++ /dev/null @@ -1,28 +0,0 @@ -# Deploy Your Project Locally -[01 Getting Started](./README.md) | [02 Examining the Project](./02-examining-project.md) | [03 Testing](./03-testing.md) | 04 Deploying Locally | [05 Deploying to Azure](./05-deploying-to-azure.md) | [06 Teardown](./06-teardown.md) - -While running the tests checks for certain values, fields, and functionality, it is still wise to get a visual confirmation that you know and like what you're deploying. - -We can give our Django application a test run using the `runserver` command. Since we're in a containerized environment, we will not use the default `127.0.0.1:8000` but instead `0.0.0.0:8000`. - -> **💻 Try It** -> ```python -> cd demo-code -> python manage.py runserver 0.0.0.0:8000 -> ``` - -https://user-images.githubusercontent.com/8632637/230239735-d702313b-58f4-4c54-bcb2-68ddd9440b17.mp4 - -This ensures that our application is connected to our database as expected and things are looking great. - -Since we're using the DB build from our docker compose, we've pre-seeded the database with some data for you. - -Our Dev Container has the ports forwarded so that even in a Codespace, you will be able to view your running project. - -https://user-images.githubusercontent.com/8632637/230453383-fe762b5c-255b-4bfe-a690-128ba683ea70.mp4 - ---- - -## Next - -Proceed to [05 Deploying to Azure](./05-deploying-to-azure.md) diff --git a/lab/05-deploying-to-azure.md b/lab/05-deploying-to-azure.md deleted file mode 100644 index 227a7a6..0000000 --- a/lab/05-deploying-to-azure.md +++ /dev/null @@ -1,82 +0,0 @@ -[01 Getting Started](./README.md) | [02 Examining the Project](./02-examining-project.md) | [03 Testing](./03-testing.md) | [04 Deploying Locally](./04-deploying-locally.md) | 05 Deploying to Azure | [06 Teardown](./06-teardown.md) - -# Deploy your project to Azure - -We've tested our project locally and now we are ready to deploy it to Azure. - -## Sign up for Azure - -If you haven't yet, you will need to create an Azure Account. If you don't have an account already you can sign up using to get up to $200 in credits. We've configured this application to use the minimal resources, but not all the resources used have a free tier. You can use the credits to pay for the resources used in this lab. - -## The Azure Developer CLI (AZD) - -The [Azure Developer CLI](https://aka.ms/azd) is a command line tool that allows us to manage our project in Azure. It uses the [Bicep](https://aka.ms/bicep) configuration language. - -We've already installed the Azure Developer CLI in our Dev Container, added some metadata in an `azure.yaml`, and provided our Bicep templates in the `infra` folder. We still need to add some information local to our individual deployments. - -> **:book: Learn More** -> -> To learn more about the Azure Developer CLI including how to install it outside of this project, visit - -Run the following command to login to Azure: - -> **:computer: Try It** -> ```shell -> azd auth login -> ``` - -> **Warning** -> -> Your `.azure` folder will contain information about your subscription as well as potentially host keys and should not be added to source control. We've already added `.azure` to the `.gitignore` file for this repo. - -## Deploying with AZD - -To get our code into Azure Container Apps with AZD, we need to provision and deploy our application. - -## Provisioning and Deploying (`azd up`) - -For this first deploy, we need to first provision (create) all the necessary Azure resources, and only once those are created, we can deploy the containerized app code. - -Use the `azd up` command to both provision and deploy: - -> **:computer: Try It** -> -> ```shell -> azd up -> ``` - -When prompted, provide a unique environment name, select a subscription in your account (you may only have one, if you're new to Azure), and select a location for the resources. - -https://user-images.githubusercontent.com/8632637/230491736-739b896e-1965-4707-8146-5a1e480ef344.mp4 - -Once the deployment is finished, visit your site by clicking the link in the output. - -https://user-images.githubusercontent.com/8632637/230491846-84d2a979-fc65-4555-a6e8-824f7034c54e.mp4 - -## Redeploying (`azd deploy`) - -You have deployed a Django application via Azure Container Apps! But what if we need to make changes? - -If you are changing the Bicep templates you will need to reprovision (using `azd up` or `azd provision`), but if you are only making changes to your project code, it is significantly faster to redeploy. You can use the command `azd deploy` to skip the provisioning setup and redeploy your application. - -> **:computer: Try It** -> -> ```shell -> azd deploy -> ``` - -https://user-images.githubusercontent.com/8632637/230491934-9e6d7f3a-3953-424b-abf8-4a71c87d5fc6.mp4 - ---- - -## Congratulations - -Congratulations, you have successfully deployed a Django Application via Azure Container Apps! - -You will likely want to tear down your resources to avoid incurring costs. Proceed to [06-Teardown](./06-teardown.md) to tear down your resources. - -### Bonus - -We've talked a lot about how we brought this project to life and how we can deploy it to Azure. We can simplify this deployment a lot by fully embracing the power of Azure Developer CLI and GitHub Actions. - -Check out the [bonus section](./bonus-07-use-azd-template.md) which walks through those steps. diff --git a/lab/06-teardown.md b/lab/06-teardown.md deleted file mode 100644 index 182e596..0000000 --- a/lab/06-teardown.md +++ /dev/null @@ -1,17 +0,0 @@ -[01 Getting Started](./README.md) | [02 Examining the Project](./02-examining-project.md) | [03 Testing](./03-testing.md) | [04 Deploying Locally](./04-deploying-locally.md) | [05 Deploying to Azure](./05-deploying-to-azure.md) | 06 Teardown - -# Tearing Things Down - -Azure Container Apps are billed by usage and ours have been configured to scale all the way down to zero if not in active use. - -That said we have created several resources and we should clean them up when we are done to avoid unnecessary charges. - -To tear down the project, we can use azd to deprovision, or remove, all of our created resources. We can run `azd down --purge` to shut down and deprovision our resources. We use the purge command to free up the namespaces around our Key Vault resources. - -```bash -azd down --purge -``` - -This will take a little bit of time to complete. - -Our resources and the associated resource group have been deleted. \ No newline at end of file diff --git a/lab/README.md b/lab/README.md deleted file mode 100644 index 853d3c9..0000000 --- a/lab/README.md +++ /dev/null @@ -1,48 +0,0 @@ -**01 Getting Started** | [02 Examining the Project](./02-examining-project.md) | [03 Testing](./03-testing.md) | [04 Deploying Locally](./04-deploying-locally.md) | [05 Deploying to Azure](./05-deploying-to-azure.md) | [06 Teardown](./06-teardown.md) - -# 🚀 Get Ready for Takeoff - -In this lab, you will deploy a Space Tourism site powered by Django and PostgreSQL using Azure Container Apps. - -![Relecloud Site](./../assets/Relecloud%20Site.png) - - -The steps below will get you up and running to deploy the Relecloud Django application to Azure Container Apps. - -> **:car:💨 Fast Track** -> -> If you are an experienced Django developer interested in learning how to deploy the application to Azure, check out our [Fast Track](./fasttrack.md). This walks you through the steps to deploy the application to Azure Container Apps, skipping the breakdown and testing stages. [Take the Fast Track](./fasttrack.md) - -## Get Started -### Create your own repo from this template - -Open the [Azure-Samples/azure-django-postgres-aca](https://github.com/Azure-Samples/azure-django-postgres-aca) repository, click the **Use this Template** button at the top right hand corner, and select **Create a new repository**. - -![The green "Use this Template" button in the top right section of the repo page on GitHub](./../assets/use-this-template.png) - -Once you have created the repo, launch the repo in GitHub Codespaces or clone it to your local machine: - -### [Option 1]: Launch in GitHub Codespaces - -You can use [GitHub Codespaces](http://aka.ms/codespaces) to launch your repo in a browser-based VS Code environment. This is a great way to get started with no local setup required. GitHub users recieve 60 free hours of Codespaces per month. - -Select the green **Code** button in the top right section of the repo page on GitHub and select **Open with Codespaces**. If you haven't created a Codespace before, you will be prompted to create one. Once created, you will be taken to your Codespace environment. - -![Create a Codespace](./../assets/create%20a%20codespace.png) - -You can choose to work inside your browser or open that Codespace using your local Visual Studio Code. - -### [Option 2]: Clone to your local machine and open as a Dev Container - -1. Open **your repo** that you have created from Azure-Samples/azure-django-postgres-aca, click Code at the top right, and on the Local tab, copy the clone command for `HTTPS`, `SSH`, or `GitHub CLI` as appropriate. -2. Run the clone command on your local machine to clone the repo locally. -3. Open the repo inside VS Code with the [Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers). ⚠️ Unfortunately, If you're on an Apple M1/M2, it's not currently possible to open this project in a Dev Container. Please use GitHub Codespaces to ensure that you have all the necessary dependencies and configurations. - -### Do I need a virtual environment and `pip install`? - -**No**, because we are operating inside of a containerized environment, we've gone ahead and installed all of the tools needed for this lab. You can see the list of tools installed in the [devcontainer.json](./../../.devcontainer_fastapi/devcontainer.json) file, as well as the [requirements.txt](./../demo-code/requirements.txt) and [requirements-dev.txt](./../requirements-dev.txt) files. - ---- - -## Next -**Proceed to [02 Examining the Project](./02-examining-project.md)** diff --git a/lab/bonus-07-use-azd-template.md b/lab/bonus-07-use-azd-template.md deleted file mode 100644 index 4f0714e..0000000 --- a/lab/bonus-07-use-azd-template.md +++ /dev/null @@ -1,35 +0,0 @@ -# Bonus: Using AZD + GitHub Actions to Manage your Deployment - -You can also redeploy your project to Azure using GitHub Actions. This will allow GitHub to redeploy your project to Azure when changes are made without manually running `azd deploy`. - -## Using GitHub Actions - -We've included a GitHub Action workflow file in [azure-dev.yaml](./../.github/workflows/azure-dev.yaml). This workflow runs the provision and deployment steps using Federated Credentials. - -To setup your GitHub repo, run the following command: - -```shell -azd pipeline config -``` - -Enter the required information. - -https://user-images.githubusercontent.com/8632637/231233580-c0f1d520-f81d-4db5-931e-2b96cb7d2ec6.mp4 - -The information required by the workflow will be added to your GitHub repo. - -![GitHub Actions Secrets and Variables](./../assets/action-secrets-and-vars.png) - -## Running the GitHub Action - -Once that is complete you can run the GitHub Action workflow. - -We've intentionally commented out the automated deployment steps but you can uncomment them to automatically deploy your project to Azure. For now, we can manually trigger the deployment using the GitHub Actions tab. - -1. Open your repo in GitHub and select the Actions tab on top left. -2. In the Actions side menu, under _All workflows_ select the _Azure Developer CLI_. -3. A blue banner that says "This workflow has a workflow_dispatch event trigger will appear in the main section of the page. Click the _Run workflow_ button. -4. A _Use workflow from_ window will appear. Click the green _Run workflow_ button. - -https://user-images.githubusercontent.com/8632637/231231358-bd5f70e4-a5e9-42c6-9c0f-33885629c529.mp4 - diff --git a/lab/fasttrack.md b/lab/fasttrack.md deleted file mode 100644 index 8ec0235..0000000 --- a/lab/fasttrack.md +++ /dev/null @@ -1,71 +0,0 @@ -# Deploying the Django application to Azure Container Apps (Fast Track) - -> **Warning** -> -> The fast track assumes that you understand all of the Python concepts discussed in the [Lab](lab/README.md). If you are not familiar with the concepts, please complete the lab before attempting the fast track. - -This fast track will guide you through the process of deploying this application from scratch. - -## Prerequisites - -- [Azure Account - Create a Free Account Today](https://aka.ms/azurefree) -- [Azure Developer CLI](https://learn.microsoft.com/en-us/azure/developer/azure-developer-cli/install-azd) - -## Deploying the application - -### Create a new folder for your project - -Replace `USERNAME` with your GitHub username. - -```bash -mkdir USERNAME-django-pg-aca -cd USERNAME-django-pg-aca -``` - -### Use AZD to load the application code - -Use the following command to extract the code into the current folder: - -```bash -azd init -t https://github.com/Azure-Samples/azure-django-postgres-aca -``` - -When prompted, enter a unique environment name. The name will become part of the Azure resource names deployed in the next step. - -### Deploy your application - -If not logged in already, use this command to login to Azure: - -```bash -azd auth login -``` - -Use the following command to deploy your application: - -```bash -azd up -``` - -When prompted, select an Azure subscription from your account and then select a location for your application. Note that free resources may be restricted in some regions. - -Your application will provision and deploy. This will take some time to complete. - - - -Once the deployment is finished, visit your site by clicking the link. - - - -## Teardown - - -> **Warning: ** -> -> **Teardown your project when finished with the lab to avoid recurring charges.** -> Though we've made an effort to utilize the cheapest and whenever possible free resources, leaving these resources running may accrue charges. Please completely de-provision your resources once no longer needed. - -You can tear down your application by running the following command: - -```bash -azd down --purge -```