platform: mac-OS language: Javascript
brew update && brew install azure-cli
az login
az login
will launch a browser instance to login.
brew tap azure/functions
brew install azure-functions-core-tools@3
func --version
Download - Did not do it because I already have it
node --version
md pwc
cd pwc
func init LocalFunctionProj --javascript
cd LocalFunctionProj
func new --name DennisSeahHttpExample --template "HTTP trigger"
func start
DennisSeahHttpExample
- a function name that I choose so that it can be unique
func start
- for me to test locally
http://localhost:7071/api/DennisSeahHttpExample?name=test
group create --name AzureFunctionsQuickstart-rg --location westus2
{
"id": "/subscriptions/dd831253-787f-4dc8-8eb0-ac9d052177d9/resourceGroups/AzureFunctionsQuickstart-rg",
"location": "westus2",
"managedBy": null,
"name": "AzureFunctionsQuickstart-rg",
"properties": {
"provisioningState": "Succeeded"
},
"tags": null,
"type": "Microsoft.Resources/resourceGroups"
}
I used westus2
because it is closer to me. Use az account list-locations
to list all locations
az storage account create --name dennisseahjssamplefn --location westus2 --resource-group AzureFunctionsQuickstart-rg --sku Standard_LRS
- there are limitation of storage account name. see here
- it takes a while to create the storage account and then you get an json like this
az functionapp create --resource-group AzureFunctionsQuickstart-rg --consumption-plan-location westus2 --runtime node --runtime-version 10 --name DennisSeahHttpExample --storage-account dennisseahjssamplefn --os-type Linux
Note: You may get an warning/error like this. please ignore it. I got stuck with this for hours and then figured that it can be ignored and proceed to publish the application.
This region has quota of 0 instances for your subscription. Try selecting different region or SKU. Please email [email protected] for more information.
func azure functionapp publish DennisSeahHttpExample
Getting site publishing info...
Uploading package...
Uploading 1.21 KB [###############################################################################]
Upload completed successfully.
Deployment completed successfully.
Syncing triggers...
Functions in DennisSeahHttpExample:
DennisSeahHttpExample - [httpTrigger]
Invoke url: https://dennisseahhttpexample.azurewebsites.net/api/dennisseahhttpexample?code=25/28blTMJ5EQIu0jdilAofzxKrZEuujTdzXaMfeV8EcmTWY1mWNBg==
- point browser to https://ms.portal.azure.com/
- under the resource group
AzureFunctionsQuickstart-r
, I am able to find my function. - able to see that status of the function (Running)
also can do this via az cli. e.g.
az functionapp show --name DennisSeahHttpExample --resource-group AzureFunctionsQuickstart-rg | jq " . | .state "
and we got
Running
Next looking at "Monitor Azure Function" see appendix - reference [4]
When creating a function app, you must create or link to a general-purpose Azure Storage account that supports Blob, Queue, and Table storage. This is because Functions relies on Azure Storage for operations such as managing triggers and logging function executions. Some storage accounts don't support queues and tables. These accounts include blob-only storage accounts, Azure Premium Storage, and general-purpose storage accounts with ZRS replication. These unsupported accounts are filtered out of from the Storage Account blade when creating a function app.
While you can use an existing storage account with your function app, you must make sure that it meets these requirements. Storage accounts created as part of the function app create flow are guaranteed to meet these storage account requirements.
{
"accessTier": null,
"azureFilesIdentityBasedAuthentication": null,
"creationTime": "2020-04-02T16:23:17.007061+00:00",
"customDomain": null,
"enableHttpsTrafficOnly": true,
"encryption": {
"keySource": "Microsoft.Storage",
"keyVaultProperties": null,
"services": {
"blob": {
"enabled": true,
"keyType": "Account",
"lastEnabledTime": "2020-04-02T16:23:17.053928+00:00"
},
"file": {
"enabled": true,
"keyType": "Account",
"lastEnabledTime": "2020-04-02T16:23:17.053928+00:00"
},
"queue": null,
"table": null
}
},
"failoverInProgress": null,
"geoReplicationStats": null,
"id": "/subscriptions/dd831253-787f-4dc8-8eb0-ac9d052177d9/resourceGroups/AzureFunctionsQuickstart-rg/providers/Microsoft.Storage/storageAccounts/dennisseahjssamplefn",
"identity": null,
"isHnsEnabled": null,
"kind": "Storage",
"largeFileSharesState": null,
"lastGeoFailoverTime": null,
"location": "westus2",
"name": "dennisseahjssamplefn",
"networkRuleSet": {
"bypass": "AzureServices",
"defaultAction": "Allow",
"ipRules": [],
"virtualNetworkRules": []
},
"primaryEndpoints": {
"blob": "https://dennisseahjssamplefn.blob.core.windows.net/",
"dfs": null,
"file": "https://dennisseahjssamplefn.file.core.windows.net/",
"internetEndpoints": null,
"microsoftEndpoints": null,
"queue": "https://dennisseahjssamplefn.queue.core.windows.net/",
"table": "https://dennisseahjssamplefn.table.core.windows.net/",
"web": null
},
"primaryLocation": "westus2",
"privateEndpointConnections": [],
"provisioningState": "Succeeded",
"resourceGroup": "AzureFunctionsQuickstart-rg",
"routingPreference": null,
"secondaryEndpoints": null,
"secondaryLocation": null,
"sku": {
"name": "Standard_LRS",
"tier": "Standard"
},
"statusOfPrimary": "available",
"statusOfSecondary": null,
"tags": {},
"type": "Microsoft.Storage/storageAccounts"
}