Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added functions doc #126

Merged
merged 9 commits into from Mar 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Binary file added docs/resources/azure-cosmos-modal.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/resources/azure-functions-extension.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/resources/azure-functions-modal.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/resources/azure-functions-portal.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
78 changes: 78 additions & 0 deletions docs/services/azure-functions.md
@@ -0,0 +1,78 @@
# Azure Functions

Azure Functions is a serverless compute service that enables you to run code on-demand without having to explicitly
provision or manage infrastructure. Think of it as deploying functions that executes on pre-defined triggers instead of
having to write and manage a full-fledged server yourself. One of the most commonly used triggers is an HTTPTrigger which
is a function that runs whenever it receives an HTTP request. This is essentially the same as an API endpoint. Web
Template Studio allows you to deploy a function app with multiple 'hello world' HTTPTrigger functions (maximum of 10) so
you can get to writing your business logic as soon as possible!

## Getting started

Deploying an Azure Function application using Web Template Studio:

![azure-functions-modal](../resources/azure-functions-modal.png)

- Click _Add Resource_ on Azure Functions under _Services_ tab

- Select a _Subscription_ and _Resource Group_ from the _Create Functions Application_ tab that just opened. Use _Create
New_ if you want to create a new subscription or resource group. _**Note:**_ New subscription will take you to the Azure
portal to create a subscription.

- Enter an _App Name_ for your function app. This name has to be globally unique since your app will be available as
`<function_app_name>.azurewebsites.net`.

- Select a _Location_ where your function app will be deployed. You want it to be closer to your users (or servers if it's
running as a back-end service helper).

- Select a _Runtime_ for your functions. This is the programming language/framework you want to write your
functions in.

- Select the _Number of Functions_ needed for your application. This number can be thought of as the number of endpoints
your application would need. You can rename your functions from the summary bar on the right side of the
application. These would be available as `<function_app_name>.azurewebsites.net\api\<function_name>`.

The _hello world_ functions deployed are pretty basic and just return _"Hello, `<name>`"_ on a query/header with the
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove the word "pretty" and "just"; it is informal speech

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Next PR, should have proofread

variable 'name'. For example: `<function_app_name>.azurewebsites.net\api\<function_name>?name=John+Doe` will return
_"Hello, John Doe"_.

## How this works

Once you hit generate, Web Template Studio creates a directory with the same name as your Function's _App Name_ under your
generated project. This is compressed to a _.zip_ and deployed (using kudu zip deploy) to your newly created function
application. _**Note:**_ For advanced users, the _arm templates_ used to deploy your application are also available
under the _arm-templates_ directory (inside your generated project).

## Functions app in Azure Portal

![azure-functions-portal](../resources/azure-functions-portal.png)

You can configure your Function Application's advanced settings (like configuring a domain, storage accounts,
delete your application etc.) from the [azure portal](https://portal.azure.com). Once you login to the portal, select
**Function Apps** from the menu bar on the left side and select your application. Your individual functions are listed
under _Functions_ and you can monitor/integrate them here. Everything you need to manage/configure about your Function
Application can be done through the portal.

## Editing your functions and deploying the changes

We strongly encourage you to install the [Azure Functions](https://marketplace.visualstudio.com/items?
itemName=ms-azuretools.vscode-azurefunctions) extension for VSCode by **Microsoft** to manage your application. This
enables you to deploy your changes with a single click and test them out immediately instead of manually deploying the
new changes. Once you have installed this extension, here's what you need to do to deploy your changes:

![azure-functions-extension](../resources/azure-functions-extension.png)

- Open your Function Application's directory in a new VSCode window. Edit your function file(s).

- Select Azure from the activity bar on VSCode and in the _Functions_ tab bar, click the `Deploy to function app...`
button and select your function application from the menu.

- You can also add new functions using the `Create function...` button.

- To remove a function, simply delete the corresponding files and all references to it and deploy again.

### Deploying manually

If you do not want to install the extension (it is _recommended_ that you install it to make your workflow easier), follow
one of the methods in the [Azure app service zip deploy tutorial](https://docs.microsoft.com/en-us/azure/app-service/
deploy-zip) to manually deploy your updated functions!