Create a Local Azure Function using TypeScript
    • Dark
      Light
    • PDF

    Create a Local Azure Function using TypeScript

    • Dark
      Light
    • PDF

    Article Summary

    #ServerlessTips - Azure Functions
    Author: Dave McCollough Technical Consultant

    In this post we will demonstrate how to create an Azure Function using TypeScript

    TypeScript is a strongly typed programming language built on JavaScript. It adds additional syntax to your JavaScript to help you and your team catch errors earlier. TypeScript code compiles to JavaScript and runs anywhere JavaScript runs.

    Prerequisites

    • Active Azure Subscription
    • Node.js. You can install Node.js for your platform here.
      * Please make sure you have Active LTS or Maintenance LTS version installed (10.14.1 recommended).
    • Visual Studio Code. You can install Visual Studio Code for your platform here.
    • Azure Functions Extension for Visual Studio Code.

    Create a TypeScript function

    1.Open Visual Studio Code and Click the Azure icon in the left-hand navigation bar.
    download 68

    2.In the Azure Functions section, click the Create New Project icon
    download 69

    3.Select or browse to the location to save your function project.
    download 71

    4.Select the language. For this example, we will use TypeScript.

    download 70

    5.Select HTTP Trigger as the template for your function.
    download 72

    6.Provide a name for your function and press the Enter key.
    download 73

    7.Select an Authorization Level. For this example, we will use Anonymous.

    download 74

    8.Visual Studio Code will generate your TypeScript Azure Function.
    9.Once this is complete, press F5 to run your function.
    10.ShapeYou can either copy/paste the URL into your browser or cmd or ctrl + click to open the URL in a browser.
    download 75

    download 77

    11.To verify that your function is working, append a question mark and name parameter to the URL as shown below:
    http://localhost:7071/api/typescript-sample-function?name=Dave

    12.After modifying the URL, the function will respond and update the browser.
    download 78

    Summary

    In this post we reviewed how to create and test a TypeScript Azure Function in your local environment.

    azure-functions1


    Was this article helpful?