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.
-
In any directory login to the Azure CLI
$ az login
This will launch a login process in your default browser. Login to Azure to continue.
Deploying the Azure Function
-
Change directories into the
Functions
project of your locally cloned repository.
$ cd ~/code/HelloAzure/HelloAzure.Functions/
-
Deploy to your Function App
$ func azure functionapp publish <FunctionAppName>
- Substitute
<FunctionAppName>
with the name of the Function App you created in Azure.
- Substitute
This will build and publish your function project to the specified Function App.
-
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>
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 messageHello, <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)