Develop Azure Functions Flashcards
What are the two things that functions contain in terms of development?
- code and config AKA functions.json
- compiled languages the config is generated automatically from annotations in code
- scripting languages you must provide the config file yourself
What is functions.json?
- defines the functions trigger, binding and other config settings
- every function has 1 and only 1 trigger
- the runtime uses this config to determine the events to monitor and how to pass data into and out of a function execution
What is the bindings property in functions.json?
- where you configure both triggers and bindings
- each binding shares a few common settings and some setting are specific to certain bindings
- Common settings are; type, direction and name
What is a function app?
- provides an exeuction context in azure for which your functions run
- organises and collectively manages apps
- contains one or more functions that are managed, deployed and scaled together
- all functions in app share the same pricing plan, deployment method and runtime version
What are some key files in a functions project?
- host.json file is in the root folder and contains runtime-specific config
- bin folder contains packages and other library files that the app requires
How can we debug azure functions locally?
- can connect them directly to live azure services and use the local.settings.json file
What is a function binding?
- a way of declaratively connecting another resource to the function
- can be input, output or both
- data from bindings is provided to the function as params
- they are optional, a function may have none or many
What is the main advantage of triggers and bindings?
- let you avoid hardcoding access to other services
How are trigger and bindings defined for different programming languages?
.NET uses decorating methods and params with C# attribs
JAVA uses decorating method and params with java annotations
- JS/Typescript/Python/PS uses the function.json schema
What is the direction property?
- all triggers and bindings have this property in the functions.json file
- for triggers the direction is always in
- input and output bindings use in and out
- some bindings support inout
How does a function project reference connection info?
- By name from its config provider
- doesn’t directly accept the connection details allowing them to be changed across environments
- the default config provider uses environment vars that are set in app settings when running in az functions service or from local settings file
How do az functions utilize identities?
- can use ID instead of secret
- support depends on the extension using the connection
- in some cases a conn string may still be required in functions
- when hosted in az functions service ID based connections use a managed ID
- sysmtem-assigned ID is default but a user-assigned can be specified with credential and clientID properties
- when ran in local envs your dev ID is used instead
What must identities have to use azure functions?
- must have permissions to perform the intended actions
- this is done by assigning an RBAC role or by specifying the ID in an access policy