Azure Serverless URL Shorter


Posted on 11/19/2020


In this project I am going to create a full serverless URL shorter. This URL shorter will run on Azure Functions and Azure Storage.

The project can be found on GitHub

const httpTrigger: AzureFunction = async function (context: Context, req: HttpRequest): Promise {
    context.log('Redirect function processed a request. Short URL : ' + context.bindingData.shortUrl);

    var url:string;

    if (context.bindings.shortUrl == null) {
       // 404
    } 
    else {
        url = context.bindings.shortUrl.Url;
    }

    context.res = {
        status: 302,
        headers: {
            "location": url
        },
        body: null
    };
};

To be continued