azure-functions-codegen-best-practices.txt•1.88 kB
Azure Functions code generation best practices:
    - Use the latest programming models (v4 for JavaScript, v2 for Python) 
    - If the project runtime is Python or Node.js, do not create a function.json file
    - Only if the project runtime is .NET, PowerShell or Java create a function.json file with the required bindings and triggers.
    - Use this extension bundles version `[4.*, 5.0.0)` in the host.json file.
    - Use Azure Functions Core Tools for creating Function Apps
    - Blob triggers should use eventgrid source
    - Generate local.settings.json during setup to manage configuration settings locally
    - Ensure the Function App is configured to use Functions Host v4
    - Prefer extension bundles over SDKs for bindings to simplify dependency management. Use the latest extension bundles available
    - For .NET Functions, use the latest SDKs and prefer the isolated process model over in-process
    - For Durable Functions, use the Durable Task Framework (DTS) for best performance and throughput
    - Set appropriate authentication levels (default: `function`)
    - Use the latest language runtime version
    - Follow language-specific project layouts and conventions
    - For python, do not use grpcio dependent packages such as azure-functions-worker, unless necessary
    - JavaScript v4 Structure:
        ```
        root/
        ├── host.json              # Function host configuration
        ├── local.settings.json    # Development settings
        ├── package.json           # Dependencies
        ├── src/
        │   ├── app.js            # Main application entry
        │   └── [modules].js      # Business logic
        └── tests/                # Test suite
        ```
    - Provide steps for testing Functions locally after code generation to ensure functionality and correctness.