Change the function name to “Set” and update the code to use “href” instead of “name” as follows: Right-click the name Function1.cs in the Solution Explorer and rename it to LinkShortener.cs. In the next dialog, choose “Azure Functions v1”, select “Http Trigger”, pick “Storage Emulator” for the Storage Account, and set Access rights to “Anonymous.” Open Visual Studio 2017 and create a new “Azure Functions” project (the template will be under the “Cloud” category).
You can download the source code for this project here.įeel free to jump ahead to follow the step-by-step instructions, or watch me follow through this blog post in a short video:
Build and Test Locally with Function App Host and Azure Storage Emulator You do not have to have an Azure account to run this on your machine. That will automatically install the Azure Storage Emulator you can use to program against tables, queues, blobs, and files on your local machine. The only prerequisite to build and run locally is Visual Studio 2017 15.5 or later, including the Azure Developer workload.
Everything is handled by serverless Azure Functions. It uses Table Storage to map codes to URLs and a Queue to process redirect counts. This blog post walks through a simple application that creates a short code for a long URL to easily reference it. Azure Storage is a quick and effortless way to store data for applications that has high availability, is secure, scales and is redundant.