Skip to content

A simple, educational Azure Functions playground project for learning and experimenting with Azure Functions using the .NET isolated worker model.

License

Notifications You must be signed in to change notification settings

fkucukkara/azure-functions-playground

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Azure Functions 101 Playground πŸš€

A simple, educational Azure Functions playground project for learning and experimenting with Azure Functions using the .NET isolated worker model.

πŸ“‹ Overview

This project demonstrates the basics of Azure Functions v4 with the .NET isolated worker model. It's designed as a learning resource for developers getting started with serverless computing on Azure.

Features

  • βœ… HTTP-triggered Azure Function
  • βœ… Blob-triggered Function with output binding (copy blob between containers)
  • βœ… .NET Framework 4.8 with isolated worker model
  • βœ… Application Insights integration
  • βœ… Ready for local development and Azure deployment

πŸ› οΈ Prerequisites

Before you begin, ensure you have the following installed:

πŸš€ Getting Started

1. Clone the Repository

git clone https://github.com/yourusername/FunctionApp101.git
cd FunctionApp101

2. Configure Local Settings

Create a local.settings.json file in the FunctionApp101 folder:

{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "UseDevelopmentStorage=true",
    "FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated",
    "APPLICATIONINSIGHTS_CONNECTION_STRING": "<your-connection-string>"
  }
}

Note: For local development, UseDevelopmentStorage=true requires Azurite to be running.

3. Run Locally

Using Azure Functions Core Tools:

cd FunctionApp101
func start

Or using Visual Studio:

  • Open FunctionApp101.slnx
  • Press F5 to start debugging

4. Test the Function

Once running, test the HTTP endpoint:

curl http://localhost:7071/api/Function1

Or open in your browser: http://localhost:7071/api/Function1

Expected response:

Welcome to Azure Functions!

Test the Blob Copy Function

  1. Ensure Azurite is running for local storage emulation
  2. Create a container named source-container in your storage
  3. Upload a blob to source-container
  4. The function will automatically copy it to destination-container

You can use Azure Storage Explorer or Azure CLI:

# Create containers (if using Azure Storage)
az storage container create --name source-container --connection-string "<your-connection-string>"
az storage container create --name destination-container --connection-string "<your-connection-string>"

# Upload a test file
az storage blob upload --container-name source-container --file test.txt --name test.txt --connection-string "<your-connection-string>"

πŸ“ Project Structure

FunctionApp101/
β”œβ”€β”€ FunctionApp101.slnx          # Solution file
β”œβ”€β”€ .gitignore                   # Git ignore rules
β”œβ”€β”€ README.md                    # This file
β”œβ”€β”€ LICENSE                      # MIT License
└── FunctionApp101/              # Function App project
    β”œβ”€β”€ Function1.cs             # HTTP trigger function
    β”œβ”€β”€ BlobCopyFunction.cs      # Blob trigger with output binding
    β”œβ”€β”€ Program.cs               # Application entry point
    β”œβ”€β”€ FunctionApp101.csproj    # Project file
    β”œβ”€β”€ host.json                # Host configuration
    └── local.settings.json      # Local settings (not in git)

πŸ“š Learning Resources

About Azure Functions

Azure Functions is a serverless compute service that enables you to run event-triggered code without having to explicitly provision or manage infrastructure.

Key Concepts Demonstrated

  1. HTTP Triggers: Functions that respond to HTTP requests
  2. Blob Triggers: Functions that respond to blob storage events
  3. Output Bindings: Declarative way to write data to external services
  4. Isolated Worker Model: Out-of-process execution model for better flexibility
  5. Dependency Injection: Using ILoggerFactory for logging
  6. Application Insights: Telemetry and monitoring integration

Useful Links

πŸ”§ Configuration

host.json

The host.json file contains global configuration options:

{
  "version": "2.0",
  "logging": {
    "applicationInsights": {
      "samplingSettings": {
        "isEnabled": true,
        "excludedTypes": "Request"
      },
      "enableLiveMetricsFilters": true
    }
  }
}

Environment Variables

Variable Description
AzureWebJobsStorage Connection string for Azure Storage
FUNCTIONS_WORKER_RUNTIME Set to dotnet-isolated
APPLICATIONINSIGHTS_CONNECTION_STRING Application Insights connection string

🚒 Deployment

Deploy to Azure using Azure CLI

  1. Create a resource group:
az group create --name rg-functionapp101 --location eastus
  1. Create a storage account:
az storage account create --name stfunctionapp101 --location eastus --resource-group rg-functionapp101 --sku Standard_LRS
  1. Create a function app:
az functionapp create --resource-group rg-functionapp101 --consumption-plan-location eastus --runtime dotnet-isolated --functions-version 4 --name functionapp101 --storage-account stfunctionapp101
  1. Deploy the function:
func azure functionapp publish functionapp101

Deploy using Visual Studio

  1. Right-click on the project in Solution Explorer
  2. Select Publish
  3. Choose Azure β†’ Azure Function App (Windows)
  4. Follow the wizard to create or select a Function App

πŸ§ͺ Extending the Project

Adding a New Function

  1. Create a new .cs file in the project
  2. Add the function class with [Function] attribute:
public class MyNewFunction
{
    private readonly ILogger _logger;

    public MyNewFunction(ILoggerFactory loggerFactory)
    {
        _logger = loggerFactory.CreateLogger<MyNewFunction>();
    }

    [Function("MyNewFunction")]
    public HttpResponseData Run(
        [HttpTrigger(AuthorizationLevel.Anonymous, "get")] HttpRequestData req)
    {
        _logger.LogInformation("Processing request...");
        
        var response = req.CreateResponse(HttpStatusCode.OK);
        response.WriteString("Hello from MyNewFunction!");
        return response;
    }
}

πŸ“„ License

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

πŸ™ Acknowledgments


Happy Coding! πŸŽ‰

If you find this project helpful, please give it a ⭐ on GitHub!

About

A simple, educational Azure Functions playground project for learning and experimenting with Azure Functions using the .NET isolated worker model.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages