DEV Community

Jacob Smith
Jacob Smith

Posted on

Introduction to Azure Functions Pt. 4 - Deploying the Azure Function

Introduction

In this post we will deploy the Azure Function we created to the resources in Azure that we created.

Prerequisites

To deploy the Azure Function we will be using the azure-functions-core-tools cli. Instructions for installing the CLI can be found here.

The azure-functions-core-tools cli will need the Azure CLI in order to authenticate you. Installation instructions for the Azure CLI can be found here

We will be using the command line in this section. Some basic knowledge of the command line will be useful.

Shell commands will be prefixed with $.

Login with the Azure CLI

To publish your function project to a Function App you must login with the Azure CLI.

  1. In any directory login to the Azure CLI

    $ az login
    
  2. This will launch a login process in your default browser. Login to Azure to continue.

Deploying the Azure Function

  1. Change directories into the Functions project of your locally cloned repository.

    $ cd ~/code/HelloAzure/HelloAzure.Functions/
    
  2. Deploy to your Function App

    $ func azure functionapp publish <FunctionAppName>
    
    1. Substitute <FunctionAppName> with the name of the Function App you created in Azure.
  3. This will build and publish your function project to the specified Function App.

  4. You should see console output similar to the following

    Getting site publishing info...
    Creating archive for current directory...
    Uploading 3.45 MB [#########################################]
    Upload completed successfully.
    Deployment completed successfully.
    Syncing triggers...
    Functions in <FucntionAppName>:
        SayHello - [httpTrigger]
            Invoke url: <FunctionAppInvokeURL>
    
  5. You may test your deployed function by visiting the Invoke url and adding a query parameter for name. If you see a response with the message Hello, <name> congrats! Your function has been deployed.

Recap

In this post we authenticated with the Azure CLI. We then deployed our function project to our Function App. Finally we verified that the function app was succesfully deployed by visiting the Invoke url.

The next step is to automate the function deployment with a CI/CD pipeline.

Top comments (0)