@azure/functions

  • Version 3.2.0
  • Published
  • 29.1 kB
  • No dependencies
  • MIT license

Install

npm i @azure/functions
yarn add @azure/functions
pnpm add @azure/functions

Overview

Azure Functions types for Typescript

Index

Namespaces

namespace @azure/functions

module '@azure/functions' {}

    interface BindingDefinition

    interface BindingDefinition {}

      property direction

      direction: 'in' | 'out' | 'inout' | undefined;
      • The direction of your binding, as defined in function.json.

      property name

      name: string;
      • The name of your binding, as defined in function.json.

      property type

      type: string;
      • The type of your binding, as defined in function.json.

      interface Context

      interface Context {}
      • The context object can be used for writing logs, reading data from bindings, setting outputs and using the context.done callback when your exported function is synchronous. A context object is passed to your function from the Azure Functions runtime on function invocation.

      property bindingData

      bindingData: ContextBindingData;
      • Trigger metadata and function invocation data.

      property bindingDefinitions

      bindingDefinitions: BindingDefinition[];
      • Bindings your function uses, as defined in function.json.

      property bindings

      bindings: ContextBindings;
      • Input and trigger binding data, as defined in function.json. Properties on this object are dynamically generated and named based off of the "name" property in function.json.

      property executionContext

      executionContext: ExecutionContext;
      • Function execution metadata.

      property invocationId

      invocationId: string;
      • A unique GUID per function invocation.

      property log

      log: Logger;
      • Allows you to write streaming function logs. Calling directly allows you to write streaming function logs at the default trace level.

      property req

      req?: HttpRequest;
      • HTTP request object. Provided to your function when using HTTP Bindings.

      property res

      res?: {
      [key: string]: any;
      };
      • HTTP response object. Provided to your function when using HTTP Bindings.

      property traceContext

      traceContext: TraceContext;
      • TraceContext information to enable distributed tracing scenarios.

      method done

      done: (err?: Error | string | null, result?: any) => void;
      • A callback function that signals to the runtime that your code has completed. If your function is synchronous, you must call context.done at the end of execution. If your function is asynchronous, you should not use this callback.

        Parameter err

        A user-defined error to pass back to the runtime. If present, your function execution will fail.

        Parameter result

        An object containing output binding data. result will be passed to JSON.stringify unless it is a string, Buffer, ArrayBufferView, or number.

        Deprecated

        Use of sync functions with context.done() is not recommended. Use async/await and pass the response as the return value instead. See the docs here for more information: https://aka.ms/functions-js-async-await

      interface ContextBindingData

      interface ContextBindingData {}
      • Context binding data. Provided to your function trigger metadata and function invocation data.

      property invocationId

      invocationId: string;
      • A unique GUID per function invocation.

      index signature

      [name: string]: any;

        interface ContextBindings

        interface ContextBindings {}
        • Context bindings object. Provided to your function binding data, as defined in function.json.

        index signature

        [name: string]: any;

          interface Cookie

          interface Cookie {}
          • Http response cookie object to "Set-Cookie"

          property domain

          domain?: string;
          • Specifies allowed hosts to receive the cookie

          property expires

          expires?: Date | number;
          • NOTE: It is generally recommended that you use maxAge over expires. Sets the cookie to expire at a specific date instead of when the client closes. This can be a Javascript Date or Unix time in milliseconds.

          property httpOnly

          httpOnly?: boolean;
          • Sets the cookie to be inaccessible to JavaScript's Document.cookie API

          property maxAge

          maxAge?: number;
          • Number of seconds until the cookie expires. A zero or negative number will expire the cookie immediately.

          property name

          name: string;
          • Cookie name

          property path

          path?: string;
          • Specifies URL path that must exist in the requested URL

          property sameSite

          sameSite?: 'Strict' | 'Lax' | 'None' | undefined;
          • Can restrict the cookie to not be sent with cross-site requests

          property secure

          secure?: boolean;
          • Sets the cookie to only be sent with an encrypted request

          property value

          value: string;
          • Cookie value

          interface Exception

          interface Exception {}

            property message

            message?: string | null;
            • Exception message

            property source

            source?: string | null;
            • Exception source

            property stackTrace

            stackTrace?: string | null;
            • Exception stackTrace

            interface ExecutionContext

            interface ExecutionContext {}

              property functionDirectory

              functionDirectory: string;
              • The directory your function is in (this is the parent directory of this function's function.json).

              property functionName

              functionName: string;
              • The name of the function that is being invoked. The name of your function is always the same as the name of the corresponding function.json's parent directory.

              property invocationId

              invocationId: string;
              • A unique GUID per function invocation.

              property retryContext

              retryContext: RetryContext | null;
              • The retry context of the current function execution or null if the retry policy is not defined.

              interface Form

              interface Form extends Iterable<[string, FormPart]> {}

                property length

                length: number;
                • The number of parts in this form

                method get

                get: (name: string) => FormPart | null;
                • Returns the value of the first name-value pair whose name is name. If there are no such pairs, null is returned.

                method getAll

                getAll: (name: string) => FormPart[];
                • Returns the values of all name-value pairs whose name is name. If there are no such pairs, an empty array is returned.

                method has

                has: (name: string) => boolean;
                • Returns true if there is at least one name-value pair whose name is name.

                interface FormPart

                interface FormPart {}

                  property contentType

                  contentType?: string;
                  • The content type for this part of the form, assumed to be "text/plain" if not specified

                  property fileName

                  fileName?: string;
                  • The file name for this part of the form, if specified

                  property value

                  value: Buffer;
                  • The value for this part of the form

                  interface HttpRequest

                  interface HttpRequest {}
                  • HTTP request object. Provided to your function when using HTTP Bindings.

                  property body

                  body?: any;
                  • The HTTP request body.

                  property headers

                  headers: HttpRequestHeaders;
                  • HTTP request headers.

                  property method

                  method: HttpMethod | null;
                  • HTTP request method used to invoke this function.

                  property params

                  params: HttpRequestParams;
                  • Route parameter keys and values.

                  property query

                  query: HttpRequestQuery;
                  • Query string parameter keys and values from the URL.

                  property rawBody

                  rawBody?: any;
                  • The HTTP request body as a UTF-8 string.

                  property url

                  url: string;
                  • Request URL.

                  property user

                  user: HttpRequestUser | null;
                  • Object representing logged-in user, either through AppService/Functions authentication, or SWA Authentication null when no such user is logged in.

                  method parseFormBody

                  parseFormBody: () => Form;
                  • Parses the body and returns an object representing a form

                    Throws

                    if the content type is not "multipart/form-data" or "application/x-www-form-urlencoded"

                  interface HttpRequestHeaders

                  interface HttpRequestHeaders {}
                  • HTTP request headers.

                  index signature

                  [name: string]: string;

                    interface HttpRequestParams

                    interface HttpRequestParams {}
                    • Route parameter keys and values.

                    index signature

                    [name: string]: string;

                      interface HttpRequestQuery

                      interface HttpRequestQuery {}
                      • Query string parameter keys and values from the URL.

                      index signature

                      [name: string]: string;

                        interface HttpRequestUser

                        interface HttpRequestUser {}
                        • Object representing logged-in user, either through AppService/Functions authentication, or SWA Authentication

                        property claimsPrincipalData

                        claimsPrincipalData: {
                        [key: string]: any;
                        };
                        • Extra authentication information, dependent on auth type and auth provider

                        property id

                        id: string;
                        • unique user GUID

                        property identityProvider

                        identityProvider: string;
                        • provider of authentication service

                        property type

                        type: HttpRequestUserType;
                        • Type of authentication, either AppService or StaticWebApps

                        property username

                        username: string;
                        • unique username

                        interface HttpResponseFull

                        interface HttpResponseFull {}
                        • Http response object and methods. This is the default of the res property in the Context object provided to your function when using HTTP triggers.

                        property body

                        body?: any;
                        • HTTP response body.

                        property cookies

                        cookies?: Cookie[];
                        • HTTP response cookies.

                        property enableContentNegotiation

                        enableContentNegotiation?: boolean;
                        • Enable content negotiation of response body if true If false, treat response body as raw false

                        property headers

                        headers?: HttpResponseHeaders;
                        • HTTP response headers.

                        property status

                        status: (statusCode: number | string) => HttpResponseFull;
                        • Sets the HTTP response status code

                          Returns

                          the updated HttpResponseFull instance

                        property statusCode

                        statusCode?: number | string;
                        • HTTP response status code. 200

                        method end

                        end: (body?: any) => HttpResponseFull;
                        • Same as send() Automatically sets the content-type then calls context.done()

                          Returns

                          updated HttpResponseFull instance

                          Deprecated

                          this method calls context.done() which is deprecated, use async/await and pass the response as your function's return value instead. See the docs here for more information: https://aka.ms/functions-js-async-await

                        method get

                        get: (field: string) => any;
                        • Has the same functionality as getHeader Get the value of a particular header field

                        method getHeader

                        getHeader: (field: string) => any;
                        • Get the value of a particular header field

                        method header

                        header: (field: string, val: any) => HttpResponseFull;
                        • Has the same functionality as setHeader. Sets a particular header field to a value

                          Returns

                          the updated HttpResponseFull instance

                        method json

                        json: (body?: any) => void;
                        • Sets the 'Content-Type' header to 'application/json' then calls send(body)

                          Deprecated

                          this method calls context.done() which is deprecated, use async/await and pass the response as your function's return value instead. See the docs here for more information: https://aka.ms/functions-js-async-await

                        method removeHeader

                        removeHeader: (field: string) => HttpResponseFull;
                        • Removes a particular header field

                          Returns

                          the updated HttpResponseFull instance

                        method send

                        send: (body?: any) => HttpResponseFull;
                        • Automatically sets the content-type then calls context.done()

                          Returns

                          updated HttpResponseFull instance

                          Deprecated

                          this method calls context.done() which is deprecated, use async/await and pass the response as the return value instead. See the docs here for more information: https://aka.ms/functions-js-async-await

                        method sendStatus

                        sendStatus: (statusCode: string | number) => HttpResponseFull;
                        • Sets the status code then calls send()

                          Returns

                          updated HttpResponseFull instance

                          Deprecated

                          this method calls context.done() which is deprecated, use async/await and pass the response as your function's return value instead. See the docs here for more information: https://aka.ms/functions-js-async-await

                        method set

                        set: (field: string, val: any) => HttpResponseFull;
                        • Has the same functionality as setHeader. Sets a particular header field to a value

                          Returns

                          the updated HttpResponseFull instance

                        method setHeader

                        setHeader: (field: string, val: any) => HttpResponseFull;
                        • Sets a particular header field to a value

                          Returns

                          the updated HttpResponseFull instance

                        method type

                        type: (type: string) => HttpResponseFull;
                        • Set the 'Content-Type' header to a particular value

                          Returns

                          the updated HttpResponseFull instance

                        interface HttpResponseHeaders

                        interface HttpResponseHeaders {}
                        • HTTP response headers.

                        index signature

                        [name: string]: string;

                          interface HttpResponseSimple

                          interface HttpResponseSimple {}
                          • Http response object. This is not the default on the Context object, but you may replace context.res with an object of this type when using HTTP triggers.

                          property body

                          body?: any;
                          • HTTP response body.

                          property cookies

                          cookies?: Cookie[];
                          • HTTP response cookies.

                          property enableContentNegotiation

                          enableContentNegotiation?: boolean;
                          • Enable content negotiation of response body if true If false, treat response body as raw false

                          property headers

                          headers?: HttpResponseHeaders;
                          • HTTP response headers.

                          property status

                          status?: number | string;
                          • HTTP response status code The same as statusCode. This property is ignored if statusCode is set 200

                          property statusCode

                          statusCode?: number | string;
                          • HTTP response status code. This property takes precedence over the status property 200

                          interface Logger

                          interface Logger {}
                          • Allows you to write streaming function logs.

                          method error

                          error: (...args: any[]) => void;
                          • Writes to error level logging or lower.

                          method info

                          info: (...args: any[]) => void;
                          • Writes to info level logging or lower.

                          method verbose

                          verbose: (...args: any[]) => void;
                          • Writes to verbose level logging.

                          method warn

                          warn: (...args: any[]) => void;
                          • Writes to warning level logging or lower.

                          call signature

                          (...args: any[]): void;
                          • Writes streaming function logs at the default trace level.

                          interface RetryContext

                          interface RetryContext {}

                            property exception

                            exception?: Exception;
                            • Exception that caused the retry

                            property maxRetryCount

                            maxRetryCount: number;
                            • Max retry count is the maximum number of times an execution is retried before eventual failure. A value of -1 means to retry indefinitely.

                            property retryCount

                            retryCount: number;
                            • Current retry count of the function executions.

                            interface Timer

                            interface Timer {}
                            • Timer schedule information. Provided to your function when using a timer binding.

                            property isPastDue

                            isPastDue: boolean;
                            • Whether this timer invocation is due to a missed schedule occurrence.

                            property schedule

                            schedule: {
                            /**
                            * Whether intervals between invocations should account for DST.
                            */
                            adjustForDST: boolean;
                            };

                              property scheduleStatus

                              scheduleStatus: {
                              /**
                              * The last recorded schedule occurrence. Date ISO string.
                              */
                              last: string;
                              /**
                              * The expected next schedule occurrence. Date ISO string.
                              */
                              next: string;
                              /**
                              * The last time this record was updated. This is used to re-calculate `next` with the current schedule after a host restart. Date ISO string.
                              */
                              lastUpdated: string;
                              };

                                interface TraceContext

                                interface TraceContext {}
                                • TraceContext information to enable distributed tracing scenarios.

                                property attributes

                                attributes:
                                | {
                                [k: string]: string;
                                }
                                | null
                                | undefined;
                                • Holds additional properties being sent as part of request telemetry.

                                property traceparent

                                traceparent: string | null | undefined;
                                • Describes the position of the incoming request in its trace graph in a portable, fixed-length format.

                                property tracestate

                                tracestate: string | null | undefined;
                                • Extends traceparent with vendor-specific data.

                                type AzureFunction

                                type AzureFunction = (context: Context, ...args: any[]) => Promise<any> | void;
                                • Interface for your Azure Function code. This function must be exported (via module.exports or exports) and will execute when triggered. It is recommended that you declare this function as async, which implicitly returns a Promise.

                                  Parameter context

                                  Context object passed to your function from the Azure Functions runtime.

                                  Parameter args

                                  Optional array of input and trigger binding data. These binding data are passed to the function in the same order that they are defined in function.json. Valid input types are string, HttpRequest, and Buffer.

                                  Returns

                                  Output bindings (optional). If you are returning a result from a Promise (or an async function), this result will be passed to JSON.stringify unless it is a string, Buffer, ArrayBufferView, or number.

                                type HttpMethod

                                type HttpMethod =
                                | 'GET'
                                | 'POST'
                                | 'DELETE'
                                | 'HEAD'
                                | 'PATCH'
                                | 'PUT'
                                | 'OPTIONS'
                                | 'TRACE'
                                | 'CONNECT';
                                • Possible values for an HTTP request method.

                                type HttpRequestUserType

                                type HttpRequestUserType = 'AppService' | 'StaticWebApps';
                                • Possible values for an HTTP Request user type

                                type HttpResponse

                                type HttpResponse = HttpResponseSimple | HttpResponseFull;
                                • Http response type.

                                Package Files (1)

                                Dependencies (0)

                                No dependencies.

                                Dev Dependencies (0)

                                No dev dependencies.

                                Peer Dependencies (0)

                                No peer dependencies.

                                Badge

                                To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@azure/functions.

                                • Markdown
                                  [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@azure/functions)
                                • HTML
                                  <a href="https://www.jsdocs.io/package/@azure/functions"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>