Skip to content

Conversation

Copy link

Copilot AI commented Sep 29, 2025

This PR converts the existing .NET 8 Azure Functions Timer Trigger template to TypeScript/Node.js while maintaining 100% functional equivalence. The conversion follows Azure Functions v4 programming model and TypeScript v4 standards as requested in the issue.

Overview

The original C# timer function has been completely converted to TypeScript while preserving all functionality:

Original C# Implementation:

[Function("timerFunction")]
public void Run([TimerTrigger("%TIMER_SCHEDULE%", RunOnStartup = true)] TimerInfo myTimer, FunctionContext context)
{
    _logger.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");
    if (myTimer.IsPastDue)
    {
        _logger.LogWarning("The timer is running late!");
    }
}

New TypeScript Implementation:

export async function timerFunction(myTimer: Timer, context: InvocationContext): Promise<void> {
    context.log(`TypeScript Timer trigger function executed at: ${new Date().toISOString()}`);
    if (myTimer.isPastDue) {
        context.warn("The timer is running late!");
    }
}

app.timer('timerFunction', {
    schedule: '%TIMER_SCHEDULE%',
    runOnStartup: true,
    handler: timerFunction
});

Key Changes

Core Function Conversion

  • Migrated from C# to TypeScript: Complete rewrite using @azure/functions v4 library
  • Preserved all functionality: Timer scheduling, run-on-startup, past-due detection, and logging
  • Modern async patterns: Uses async/await for better performance and readability
  • Enhanced type safety: Strict TypeScript mode enabled for improved code quality

Project Structure Updates

  • New TypeScript structure: Organized code in src/functions/ following best practices
  • Build system: Added npm-based build process with TypeScript compilation
  • Dependencies: Uses @azure/functions v4 with TypeScript v4 support
  • Development tools: Hot reload with tsc -w and source map support

Infrastructure Configuration

  • Runtime migration: Updated from dotnet-isolated to node (version 18) in Bicep templates
  • Azure Developer CLI: Modified azure.yaml to use JavaScript language setting
  • Local development: Updated local.settings.json for Node.js runtime

Documentation

  • Complete README overhaul: Updated all instructions for TypeScript/Node.js development
  • Prerequisites updated: Changed from .NET 8 SDK to Node.js 18 LTS requirements
  • Build instructions: Added npm-based commands for building and running the function

Functional Equivalence Verification

All original features are preserved:

Feature Status
Timer schedule via TIMER_SCHEDULE environment variable ✅ Maintained
Run on startup for development/testing ✅ Maintained
Past due detection with appropriate warnings ✅ Maintained
Execution time logging ✅ Maintained
Secure deployment with managed identity ✅ Maintained
VNet integration support ✅ Maintained

Usage

The converted template maintains the same ease of use:

# Install dependencies
npm install

# Build TypeScript
npm run build

# Run locally
npm start

# Deploy to Azure
azd up

This conversion provides developers with a modern TypeScript alternative while maintaining all the security, scalability, and deployment benefits of the original template.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • cdn.functions.azure.com
    • Triggering command: node lib/install.js (dns block)
  • https://api.github.com/repos/Azure-Samples/Azure-Samples%2Ffunctions-quickstart-dotnet-azd-timer/languages
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node --enable-source-maps /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Convert to Typescript/Node</issue_title>
<issue_description>This is the base template written in .NET 8. Please convert this in a new branch for TypeScript / Node.js. I want 100% functional equivalence and documentation, however it should be in the style of TypeScript v4. See this HTTP TypeScript sample as a reference for ideal style, and this reference documentation for Typescript v4. </issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes #11

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits September 29, 2025 17:58
…mplete

Co-authored-by: paulyuk <1968137+paulyuk@users.noreply.github.com>
…omplete

Co-authored-by: paulyuk <1968137+paulyuk@users.noreply.github.com>
Copilot AI changed the title [WIP] Convert to Typescript/Node Convert .NET 8 Azure Functions Timer Trigger template to TypeScript/Node.js Sep 29, 2025
Copilot finished work on behalf of paulyuk September 29, 2025 18:04
@im-samz
Copy link
Contributor

im-samz commented Nov 3, 2025

I put this generated content into https://github.com/im-samz/functions-quickstart-typescript-azd-timer. We can close.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Convert to Typescript/Node

3 participants