How to deploy azure function (executed on schedule) with code as string (in c#) to given azure functions app?
I am going to use ARM template to deploy azure fund app (+ all it needs) https://github.com/Azure/azure-quickstart-templates/tree/master/101-function-app-create-dynamic, which can be deployed via code;
But I don't see ways to deploy function to function app via code.
+ A little more context: deployment is going to happen from an app service, so it's preferred not to have any dependencies beyond NuGet. E.g. I don't like the idea to call azure cli from c#.
As Jesse Carter mentioned that we could use Kudu Zip Api to do that. I do a demo for that. It works correctly on my side. The following is my detail steps:
Preparation:
Registry an AD application and assign role to applcation, more details please refer to Azure official tutorials. After that we can get tenantId, appId, secretKey from the Azure Portal.
1.Prepare an authentication file, we could get more information from github document.
2.Zip the need to be published file
Steps:
1.Create a C# console project
2.Reference the Microsoft.Azure.Management.ResourceManager.Fluent and Microsoft.Azure.Management.AppService.Fluent, more detail info please refer to the packages.config file section.
3.Add the following code in the Program.cs file
4.Test from the local
5.Check the published result from the Azure kudu tool(https://yourazurefunctionanme.scm.azurewebsites.net/)
packages.config
If you're going to deploy the function itself directly from code as opposed to using a CI/CD pipeline then your best bet is to use the Kudu REST APIs to upload the function code as a zip to the running function app. You should be able to make do using HttpClient or any of the other .NET REST libraries.