Skip to content

Example Python Azure Function App project using the Cookiecutter API template.

License

Notifications You must be signed in to change notification settings

Code-and-Sorts/cookie-py-az-func-api

Repository files navigation

Kitten-Claws API

Important

This example Python Azure Function API was generated using the Cookiecutter API template.

Overview

This project is a Python-based REST API built using Azure Function Apps. The API leverages Azure's serverless architecture, allowing you to deploy and scale functions effortlessly in the cloud. The HTTP-triggered functions serve as the endpoints for the API, providing a seamless way to handle client requests.

The REST API has the following endpoints:

  • GET (by ID)
  • GET (list)
  • POST
  • PATCH
  • DELETE (soft-delete)

Dependency management is handled using Poetry, ensuring a streamlined and consistent environment for managing Python packages and their dependencies.

Features

  • Azure Function Apps: Utilizes Azure's serverless platform to create scalable and efficient endpoints with HTTP triggers.

  • Python-Based: Written entirely in Python, leveraging its rich ecosystem and libraries for rapid development.

  • Poetry for Dependency Management: Manages all Python dependencies with Poetry, making the development environment consistent and easy to set up.

  • Cosmos DB NoSQL Account: This project uses Cosmos DB NoSQL database.

Prerequisites

  • Python >=3.7, <=3.11

  • Azure Functions Core Tools: To run the Function Apps locally.

  • Azure CLI: To deploy and manage Azure Function Apps.

  • Poetry: For dependency management and virtual environment setup.

  • Azure Account: An active Azure subscription for deploying the Function App.

  • Cosmos DB NoSQL Account either deployed in Azure or emulated.

Setup and Installation

  1. Install Azure Functions Core Tools

    Follow the documentation to install Azure Function Core Tools based on your operating system.

  2. Install Poetry

    If you haven't already installed Poetry, you can do so by following the official installation guide.

  3. Install Dependencies

    Install all dependencies and set up the virtual environment:

    make install

    To be able to run the project locally, set the environment variable values in the local.settings.json project file.

  4. Run the API Locally

    make run

    This command starts the local development server using the Azure Function Core Tools, where you can interact with your API endpoints.

  5. Thunderclient

    Included in the project is a Thunderclient collection in the .thunderclient directory to easily test the locally hosted APIs.

Development Workflow

Adding a New Dependency

poetry add <package-name>

Removing a Dependency

poetry remove <package-name>

Running Tests

Ensure your code is working as expected by running unit tests using pytest:

make test

Repository structure

├── cookiecutter-template-python
│   ├── .thunderclient     - Thunderclient collection
│   ├── blueprints         - Function App methods
│   ├── controllers        - Controllers
│   ├── errors             - Custom errors
│   ├── models             - Pydantic models
│   ├── repositories       - Cosmos DB repository
│   ├── services           - Services
│   └── utils              - Error detect & response generator utilities
│
└── function_app.py        - Function App entry method

License

This project is licensed under the MIT License. See the LICENSE file for details.


Repository generated with Code-and-Sorts/cookiecutter-api.

About

Example Python Azure Function App project using the Cookiecutter API template.

Topics

Resources

License

Stars

Watchers

Forks