Skip to content

Latest commit

 

History

History
152 lines (97 loc) · 6.54 KB

README.md

File metadata and controls

152 lines (97 loc) · 6.54 KB

Azure Functions

Examples

Product Manager

This project demonstrates how to develop an Azure Function application that can be used to manage a catalog of products. There are multiple versions of the same project where each new version increases in functionality and complexity.

The goal of this project is to introduce Azure Function concepts by slowly introducing them in different project versions. The following Azure Function concepts will be demonstrated:

  • Azure triggers (http, blob, servicebus)
  • Azure bindings (blob)
  • In-process and Isolated Process
  • Dependency Injection
  • Local development
  • Infrastructure as Code (Bicep, Azure CLI, Azure Powershell)

The available versions are as follows:

  • Version 1

    Create inital Product Manager Function App having the following functionality:

    • Add 'ProductsFunction' function (HTTP Triggered) to serve as products API.
  • Version 2

    Extend Product Manager Version 1 with the following changes:

    • Add depedency injection
    • Use in-memory database provided by Entity Framework
    • Modify 'ProductsFunction' function to use dependency injection and in-memory database
    • Add 'SeedFunction' function to help seed the products database
  • Version 3

    Extend Product Manager Version 2 with the following changes:

    • Modify the 'ProductsFunction' function to include product images
    • Add Azure Storage integration to store product images
    • Add 'user secrets' to store connection information
  • Version 4

    Extend Product Manager Version 3 with the following changes:

    • Add 'ProductImageResizerFunction' function that uses a 'Blob Trigger' to react to newly uploaded product images by resizing product images to 3 sizes (xs, sm, md) and uploading them to an Azure Storage Container.
    • The 'ProductImageResizerFunction' function also saves new product image data to a relevant product in the database.
    • Update 'ProductsFunction' function to accomodate additional product image information.
  • Version 5

    Extend Product Manager Version 4 with the following changes:

    • Use Cosmos Db as primary database
    • Add CosmosDbService as a convenient wrapper of CosmosClient
    • Create ProductService to handle all product management
    • Create ProductImageService to handle all product image requirements
    • Introduce hashing to produce product entity id
    • Create ProductFaker (uses Bogus library) to seed Cosmos Db database

Configure Your Environment

Before you get started, make sure you have the following requirements in place:

You also need an Azure account with an active subscription. Create an account for free


Getting Started

Configure Local Azure Storage

All Azure Function examples require access to Azure Storage. For development, the [Azurite] emulator is recommended by Microsoft for local Azure Storage development.

According to the official Microsoft documentation:

The Azurite open-source emulator provides a free local environment for testing your Azure blob, queue storage, and table storage applications.

Find more information about Azurite by visiting the following links:

I recommend using Azurite via the NPM approach as follows:

# Install Azurite

npm install -g azurite
# Run Azurite

azurite --silent --location ~/azurite --debug ~/azurite/debug.log
# Get Help
azurite -h
azurite --help

Access Azure Storage

Azure Storage Explorer

Azure Storage Explorer allows one to upload, download, and manage Azure Storage blobs, files, queues, and tables, as well as Azure Data Lake Storage entities and Azure managed disks.

Download the official tool offering from microsoft called Azure Storage Explorer

Azure Tools Visual Studio Code Extension Pack

Alternatively, if you have not done so already, install the Azure Tools extension pack for Visual Studio Code.

Open Workspace

Product Manager

# open product manager workspace folder
cd azure-dotnet-examples/functions/product-manager

# open product manager workspace
code ./product-manager.code-workspace