{"id":21017420,"url":"https://github.com/mkader/python_django_postgresql_azure_app","last_synced_at":"2026-03-19T18:28:17.894Z","repository":{"id":163669135,"uuid":"638672287","full_name":"mkader/python_django_postgresql_azure_app","owner":"mkader","description":null,"archived":false,"fork":false,"pushed_at":"2023-05-11T20:40:41.000Z","size":2125,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-13T17:17:27.434Z","etag":null,"topics":["learning","microsoft-learning"],"latest_commit_sha":null,"homepage":"","language":"Bicep","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mkader.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-05-09T21:19:28.000Z","updated_at":"2023-12-28T21:26:39.000Z","dependencies_parsed_at":null,"dependency_job_id":"78b4cd8e-10f9-4699-a912-ee3742a3120e","html_url":"https://github.com/mkader/python_django_postgresql_azure_app","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mkader/python_django_postgresql_azure_app","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkader%2Fpython_django_postgresql_azure_app","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkader%2Fpython_django_postgresql_azure_app/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkader%2Fpython_django_postgresql_azure_app/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkader%2Fpython_django_postgresql_azure_app/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mkader","download_url":"https://codeload.github.com/mkader/python_django_postgresql_azure_app/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkader%2Fpython_django_postgresql_azure_app/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264504615,"owners_count":23618831,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["learning","microsoft-learning"],"created_at":"2024-11-19T10:19:23.356Z","updated_at":"2026-02-06T15:35:35.491Z","avatar_url":"https://github.com/mkader.png","language":"Bicep","funding_links":[],"categories":[],"sub_categories":[],"readme":"Azure Cloud Database for Web Apps  with Django\n\n    Django honeyspot is a security feature in Django, which is a Python-based web framework. \n    The honeyspot feature is designed to protect web forms against spam and automated attacks \n    by creating a \"honeypot\" field that is invisible to human users but visible to bots. Bots \n    that try to fill out the honeypot field are considered to be spam and their submissions are rejected.\n\n    Writing Django Apps\n    \n        Django framework : an external library \u0026 framework for server-side code. Includes \n        an ORM for database interaction.\n\n        Apps written in Django:\n            Coursera (originally, now Scala+Play)\n            Instagram\n            Pinterest (originally, now Flask)\n            Eventbrite\n\n        Django web app structure - a collection of \"apps\" that each have their own models, \n        views, and templates. Each app has its own folder. In this app, we have a single \n        app called \"restaurant_review\": models.py, urls.py, views.py, admin.py\n\n        Django ORM\n            Define models (models.py):\n                class Restaurant(models.Model):\n                    name = models.CharField(max_length=50)\n           \n            Query models (views.py):\n                def details(request, id):\n                    restaurant = get_object_or_404(Restaurant, pk=id)\n           \n            Insert models (views.py):\n                restaurant = Restaurant()\n                restaurant.name = name\n                Restaurant.save(restaurant)\n\n        Configuring Django ORM  (settings.py)\n            DATABASES = {\n                'default': {\n                    'ENGINE': 'django.db.backends.postgresql',\n                    'NAME': os.environ.get('DBNAME'),\n                    ...\n                }\n            }\n\n        Check SQLTools Local Database (Make sure that .vscode/settings.json show match exactly \n        like .env to connect local db)\n        \n        Running a Django app\n            python3 -m pip install -r requirements.txt\n            Run DB migrations: python3 manage.py migrate\n            Run the local server: python3 manage.py runserver\n            Create Admin account,open a new terminal: python3 manage.py createsuperuser\n                Admin : https://mkader-...preview.app.github.dev/admin\n    \nHosting Django apps on Azure\n\n    Azure App Service has special code to handle Django apps. Let's use that!\n\n    App Service + PostgreSQL inside VNet (Virtua Network) (App inside VNet with Postgres)\n       \n       Put both the progress server and the web app inside the virtual net, give the postgres \n       service (called a private DNS Zone) that enables the web app to talk to it. \n\n       Give each of them their own subnet inside the v-net.\n       \n       This is roughly going to set up, this is a little complicated\n \n![alt](https://raw.githubusercontent.com/mkader/python_django_postgresql_azure_app/main/app_inside_vnet.PNG) \n\n    Ways to deploy multiple resources on Azure\n        Azure Portal (Web App + DB Template)\n        Azure CLI script\n        Azure Developer CLI (azd) \n\n        \"RUN curl -fsSL https://aka.ms/install-azd.sh | bash\"\n        \"-fsSL\" are command-line options for curl:\n            \"-f\" option means to fail silently on server errors.\n            \"-s\" option means to mute the output and only display errors.\n            \"-S\" option means to show errors if they occur.\n            \"-L\" option means to follow redirects if any.\n        \"|\" (pipe) is a cmd-line operator,redirects the o/p of the cmd on the left to \n            the i/p of the cmd on the right.\n        \"bash\" is a cmd-line interpreter used to execute the script that installs the Azure CLI.\n    \n        The cmd downloads the script that installs the Azure CLI and executes it in the \n        Docker container during the build process.\n\n    Azure Developer CLI (azd): This new CLI tool helps with all steps of the dev cycle:\n        Step\t        Command\n        Provisioning\tazd provision\n        Deploying code\tazd deploy\n        ⬆️ Both\t        azd up\n        CI/CD\t        azd pipeline config\n        Monitoring\t    azd monitor\n    \n    Components of an azd project\n        infra/\t    Contains all the infra in Bicep or Terraform files\n        azure.yaml\tSpecifies what code to deploy to which resource\n        .github/\tContains CI/CD workflow for deploying\n\n        https://learn.microsoft.com/en-us/azure/developer/azure-developer-cli/make-azd-compatible?pivots=azd-convert\n\n    azd up: First provisions, then deploys. Only re-provisions when Bicep resource \n            definitions have changed.\n\n    The Bicep language: is an infrastructure-as-code (IAC) language, similar to Terraform \n    but designed for Azure. Bicep declaratively defines Azure cloud resources. Install the \n    Bicep extension for VS Code to write bicep files.\n        \n    https://azure.github.io/awesome-azd/\n\n    https://mattruma.com/cheat-sheet-azure-cli/\n\n    http://blog.pamelafox.org/\n    \n    https://pamelafox.github.io/my-py-talks/pyday-databases/#/38\n    \n    https://github.com/Azure-Samples - use lab.\n    \n    Terminal, type:\n        azd\n        azd auth login\n        azd up\n\n    Only code changes, not infra, just deploy : azd deploy\n\n    Configures the secrets for .github/workflow/azure-dev.yaml, a Github workflow that provisions and deploys: azd pipeline config\n\n    No longer need the resources, delete them (everything in the resource group: azd down\n\nDjango + App Service (No VNet) : https://github.com/pamelafox/django-quiz-app\n    Uses firewall rules to limit access to the server to only Azure IPs, and stores password in key vault.\n    Architecture diagram: Azure Web App, PostgreSQL server, Key Vault\n    ![djano_no_vnet](https://github.com/mkader/python_django_postgresql_azure_app/assets/3132680/3b8ffb36-5565-4ce7-9752-1f77324bd9b3)\n    \nDjango + App Service + Redis : github.com/pamelafox/cookiecutter-django-output\n    Uses Redis as backend for cache and Celery, plus Azure storage for static assets and media uploads.\n    Architecture diagram: Azure Web App, PostgreSQL server, Redis, Storage\n    ![diagram_cookiecutter](https://github.com/mkader/python_django_postgresql_azure_app/assets/3132680/711e7dfe-f8e2-42b2-b88c-7b2a074fd22d)\n    \nDjango + App Service + Storage: github.com/tonybaloney/django-on-azure  \n    Uses Azure storage containers for static assets and media uploads, plus Azure Monitor and Azure Load Testing.\n    Architecture diagram: Azure Web App, PostgreSQL server, VNet, Storage, Load Testing\n    \u003cimg width=\"1057\" alt=\"diagram_djangoworkshop\" src=\"https://github.com/mkader/python_django_postgresql_azure_app/assets/3132680/05b29737-971c-4102-bec4-cb5701230378\"\u003e\n\nDjango + Azure Container Apps: github.com/Azure-Samples/azure-django-postgres-aca\n    Deploys a containerized version of the previous app.\n    Architecture diagram: Azure Container Apps, Postgres\n    ![diagram_acadjango](https://github.com/mkader/python_django_postgresql_azure_app/assets/3132680/4c2db806-60fc-4b51-a0f4-9d5ddfdfa15d)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmkader%2Fpython_django_postgresql_azure_app","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmkader%2Fpython_django_postgresql_azure_app","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmkader%2Fpython_django_postgresql_azure_app/lists"}