Creating Azure Functions programmatically - azure

I´m looking at Azure Functions capabilities and the documentation does not say anything about uploading, creating or deleting a Function programmatically, nor anything about listing enabled/disabled Functions. Any ideas on how to do that? The Azure API reference has no section for Azure Functions.

This functionality exists within the Azure CLI toolset.
Here is a guide on creating functions via the CLI
Documentation for the functions segment of Azure CLI
Hopefully these two resources should help get started. If you were looking for a publicly facing API, you may be out of luck.

You can create functions from the cli using:
func new
Alternatively you can pass in some parameters (not required):
func new --language JavaScript --template HttpTrigger --name MyFunction
If you don't pass in the parameters, you are prompted with the questions and you can choose the correct options.
I've done deletion by removing the function specific folder and then deploying the application again.

Related

Editing Java Function Apps is not supported in the Azure portal error

So, when I am trying to create a function inside a function app it shows Editing Java Function Apps is not supported in the Azure portal.
The Add button is not working and only local development option is present.
How can I overcome this problem?
Currently, it seems that we cannot create Java Function on Azure portal, because creating Java Function requires Maven or Gardle, but Azure portal does not seem to contain them.
So we can only develop Java Function locally and then deploy them to the Azure portal.
If you want to get this feature, you can go to the Feedback page to post your thoughts, and the Azure development team may adopt your suggestions.
By the way, not only Java, only script programming languages can be added to Azure Portal. In other words, Azure Portal can only create functions that use languages that do not require compilation
You might say that C# can be created directly on Azure portal, but the c# function created in Azure Portal is actually the c# script.

how to create Azure Functions from Azure python sdk?

Any examples on how to create Azure Functions with Azure Python SDK ?
is https://learn.microsoft.com/en-us/python/api/azure.mgmt.web.models.Site?view=azure-python a correct reference for it?
Explicit examples, at my knowledge there is not. But it's definitely using the azure-mgmt-web package you point at. You need to create an AppPlan (or serverfarm), and then a webapp of kind "functionapp".
The closest to an example would probably to look at what the Azure CLI (written in Python) is doing:
https://github.com/Azure/azure-cli/blob/e0c49d6fd4778b8e0c8884a54bca1716a916763e/src/command_modules/azure-cli-appservice/azure/cli/command_modules/appservice/custom.py#L1613-L1684

Web-Based Initiation of Creation of IaaS in Azure

I want to create an automation demo for customers, where I have a single page web app with a couple of input text fields, and the inputs get used as parameters in the creation of an Azure Resource Group and VNETs/VMs/etc within the Resource Group.
I can do all of the above with Azure CLI (v2.0) on my laptop, and also from CLI using a Azure CLI in a bash script on a Linux server, but I wanted something web-based. I considered standing up a web page on the Linux server to call the bash script, but that seems a bit painful (especially with permissions etc). I also thought maybe Azure Functions could provide a solution to host the single web page app and call the Azure CLI commands, but I've never used Functions before so not sure if Functions can do this; the description of Functions' capabilities aren't clear to me.
What is the best way to achieve what I'm after, quickly?
Note I'm not a developer, I'm a network engineer, so whilst I can hack around in a few languages from Notepad and vi, I'm not looking to build something in a full SDK, or have something with enterprise-level reliability, version control, etc. This is really all about proof of concept and web-based demo of something I already have in Azure CLI / bash script.
Thanks in advance :-)
For a quick and relatively dirty way, you could create an Azure Runbook (using the scripts created from the Azure Portal) and invoke using the Automation API This could use the scripts (or close to) what you already have.
When you roll out a new service in Azure you get the option now to download the Automation Script, you can then follow this article to deploy the generated script via a runbook
To follow on from Jamie's idea.
You can code your Azure Cli script (or Powershell) into an Azure Automation Runbook, you can have variables etc to access it with.
You can then attach a webhook to that runbook, and call it from a standard HTTP Post request.
Meaning you could create a HTML form, that would pass whatever variables are required and build whatever is needed.
The downside of this would be that you will be creating it on your infrastructure.
You can have a solution that will deploy to someone else's infrastructure with a deploy to Azure button
This lets you host it in Github etc, it takes a bit more knowledge to make it work but saves your account dollars!

Adding connection settings during runtime for Azure Function App

I'm searching for ways to modify and edit app settings for Azure function during runtime.
from the links below, I was able to find how to add bindings locally and add connection settings through azure portal or Azure Cli
https://learn.microsoft.com/en-us/azure/azure-functions/functions-run-local#local-settings-file
https://learn.microsoft.com/en-us/azure/azure-functions/functions-dotnet-class-library#environment-variables
However, I'm searching for ways to generate new connection setting variables as well as new bindings at runtime.
The use case would be, where we need to onboard users without manually interacting with the Azure function app configuration.
I also tried modifying it thorough an example given in below link:
https://learn.microsoft.com/en-us/azure/azure-functions/functions-reference-csharp#environment-variables
I was able to modify the variable temporarily, but it appears that it loses the changes as soon as the run gets terminated (also, it didn't work when I published the app on Azure).
Is there way to accomplish this during runtime?
My set up is to have two azure functions:
1. dedicated to modifying app settings if change is detected in CosmosDB where new user information is added.
2. dedicated sending messages, but generating bindings based on app configurations added by azure function 1.
My initial thoughts were to store the whole app settings in cosmosDB and generate appsettings based on that document at every onetime, but I'm pretty sure there is better ways to do this.
also, it looks like my connection strings in local.settings.json don't get reflected when I actually publish them. what am I missing?
Thanks, in advance :)

How to expose utility functions within the Azure Portal

I would like to add some operational utility functions to my 100% Azure hosted application together with the ability to manually launch these utilities at arbitrary times in the day via the Azure Portal.
My current Azure technology stack is comprised of Web(Api)Apps, Function Apps, CosmosDb + DocumentDbApi and Azure Storage Queues. The application does not have an HTML front end.
An example of a utility function would be to reset demo tenant data in CosmosDb. One benefit of using the portal UI is that I would not have to authenticate invocation of my utility functions from a remote source.
I code exclusively in C# and to date scripting languages have been a personal no-go zone.
My current thinking is that I should create a "utilities" Function-App and then launch a function when required via the portal function-test feature. Is there a better option?
I created a function app via the Azure Portal and a new function to invoke my utility code. Within the Azure Portal under the C# template options for a new function, there is "Manual" option described as follows "A C# function that is triggered manually via the portal "Run" button".
In the absence of extra official Microsoft documentation I assume this is an isolated function hosted within a function App with no external bindings such as a Storage Queue. This provides a solution to my question as I hope there is no alternative invokable public URL endpoint linked to such a manual function.

Resources