reate your first serverless app
Select the button to create a new project in the Azure Functions explorer

Select a new, empty folder to contain your project
Select your desired programming language
Select "HTTP trigger" for your project's first function
Use "HttpTrigger1" as the function name
Select "Anonymous" for the authorization level, which enables anyone to call your function endpoint without a key.
To learn more about authorization levels, see here.
If the selected folder is not already open, select "Open in current window" to open it
Run the serverless app locally
This extension integrates with the Azure Functions Core Tools to let you run your project locally before publishing to Azure.
To start your project, press F5 or the "play" button

If you do not have the Azure Functions Core Tools installed, you will be automatically prompted to install. Follow the specified instructions, or skip to the "Deploy" step if you would rather deploy without running locally.
TIP: The "Terminal" panel should pop up automatically and you know your project is running if you see output
Expand your local project in the Azure Functions explorer to copy your function's url

Navigate to a browser, paste the url, and append
?name=worldTIP: Your url should look like this:
http://localhost:7071/api/HttpTrigger1?name=worldA response of "Hello world" is returned in the browser and you know your function worked!
Select the "Detach" button to stop your project from running locally

Deploy to Azure
Sign in to your Azure Account by clicking "Sign in to Azure..." in the Azure Functions explorer
If you don't already have an Azure Account, click "Create a Free Azure Account"
Select the 'plus' button to open the "Create Resource" menu

Choose "Create Function App in Azure..."

Enter a globally unique name for your Function App
If multiple versions of your language's runtime are supported (i.e. Node.js 10 and Node.js 12), select your desired version (the latest is recommended)
Select a location
Wait for your Function App to be created. Progress will be shown in the Activity Log panel

Once your Function App has been created, reveal the resource in the Resources view.

Right click your Function App and select "Deploy to Function App"

Once deployment is complete, expand your subscription in the Azure Functions explorer to copy your deployed function's url

Navigate to a browser, paste the url, and append
?name=worldTIP: Your url should look like this:
https://<function app name>.azurewebsites.net/api/HttpTrigger1?name=worldA response of "Hello world" is returned in the browser and you know your function worked!
No comments:
Post a Comment