Azure- update function code in Function App using CLI - azure

I want to update the code in one of the functions in my Function App using CLI.
I can't find the appropriate command to do so using az functionapp.
What is the best wat yo do this, not using the portal?

If you want to update Function App , you can use the CLI command,
az functionapp update --name MyFunctionApp --resource-group MyResourceGroup
However best practice is to automate by using Azure Devops or GithubActions

You can use the Azure Functions Core Tools:
func azure functionapp publish <FunctionAppName>

Related

Functions get Remove when zip deploy function app using Azure CLI or PowerShell

I'm facing an issue while deploying the azure function using Azure CLI or Azure PowerShell.
I have already created needed resources like resource group, function app and blob storage.
My function app platform type is Linux with consumption plan and runtime net6.0. I have created Service Bus trigger function and deployed using Visual Studio Publish profile and it is working as expected.
But when I executed the command to deploy the Azure function using CLI. Command is executing successfully but when I open the function app from azure portal and go to functions blade the deployed functions do not appear there.
I also checked the folder structure of the build output as mentioned in the link
https://learn.microsoft.com/en-us/azure/azure-functions/deployment-zip-push
any help would be appreciated.
Thanks
Reproduced the same issue from our end using Az-CLI
az functionapp deployment source config-zip -g <Resource Group> -n <Function App Name> --src <Function Project with Zip>
Workaround to fix the issue
After setting SCM_DO_BUILD_DURING_DEPLOYMENT to true in Configuration > Application Settings of the Azure Function App in Portal and deployed again using AZ CLI commands and shown the functions in Portal and in Kudu site of wwwroot folder.
AZ CLI Command:
az functionapp deployment source config-zip -g HariTestRG -n KrishNet6FuncApp --src "C:/Users/Hari/source/repos/DotNet6/TimerTrigger1205.zip"
According to this MS DOC, we came to know that some deployment customization has to be done before deploying the Function App as a Zip Push, i.e., by default the app setting SCM_DO_BUILD_DURING_DEPLOYMENT is false which enables the continuous integration deployment.
For the PowerShell Workaround, refer GitHub Page.
Function App running on Linux OS in consumption plan has limited deployment options but supports only remote build.
To enable remote build on Linux, the following application settings must be set:
ENABLE_ORYX_BUILD=true
SCM_DO_BUILD_DURING_DEPLOYMENT=true
If your project needs to use remote build, don't use the
WEBSITE_RUN_FROM_PACKAGE app setting.
Functions Core Tools is the only solution work for me.
By default, Azure Functions Core Tool perform remote builds when deploying to Linux. Because of this, it automatically create these settings for you in Azure.
func azure functionapp publish <FunctionAppName>
my custom script file
param(
[Parameter(Mandatory=$True)]
$AppName,
[Parameter(Mandatory=$True)]
$LocalProjectPath
)
cd "$($LocalProjectPath)"
func azure functionapp publish $AppName
cd ..
if you need more help with Linux hosting use this link Zip Deploymnet to get detailed information related to Azure Functions Deployments.

Azure Functions Core Tools vs CLI aka how to have the list of functions within a functionapp

I need to have the list of functions deployed into an Azure Function App from command line (to be honest I need it into an Azure Devops Pipeline).
It seems that the only way to have this info is throught the command line func azure functionapp list-functions available in azure-functions-core-tools#3
Or in other words, I was unable to do the same thing with az functionapp ... which seems to be the equivalent of func for Azure CLI.
I there any (other then func) easy way to have the list of functions deployed with an Azure Function App?

Disable Azure function via AzureCLI does not disable function

I have a function app in Azure that has several functions defined. According to this document, I can use AzureCLI to disable a function in a function app. When I run az functionapp config appsettings set --name $functionAppName --resource-group $resourceGroupName --settings AzureWebJobs.myFunction.Disabled=true it creates the name value pair in application settings as stated in the documentation, but the state of the function does not toggle according to the value I set. Is something else required to toggle the state of the function when I run the AzureCLI commmand?
According to the comments, the problem was solved. OP change the azure function runtime from 1.x to 2.x and then it can be disabled by running this command.
az functionapp config appsettings set --name $functionAppName --resource-group $resourceGroupName --settings AzureWebJobs.myFunction.Disabled=true
Update1:
Update2:
For this problem, I confirmed with azure support team. They provided me with the response below:
They found the feature of az function app config part was released at Sep. 2018, and at that time runtime v1 was already quite out of date. So it is possible that the product team only develops for the runtime v2.
In a word, we can just do this operation on v2 and v3, or use Azure Portal UI.
For the guys who use the runtime 1.x but wanna enable/disable function by Azure CLI. According to the document, it shows:
So the workflow is:
Click APP Service Editor.
Comment out disabled field on function.json.
Run below command again.
az functionapp config appsettings set --name $functionAppName --resource-group $resourceGroupName --settings AzureWebJobs.myFunction.Disabled=true
This function will reference the app setting to determine it status.

What is the new AZ command to get logic app list using Powershell?

I can get we apps using the Az cmdlets by using az webapp list.
I have logic apps , I tried using az logicapp list
but its not recognised in Powershell.
Is there a manual listing the cmdlets to list logic apps ,sqlservers and sqldatabases ?
I wanted to provide an update to #4c74356b41's answer since it has been almost 3 years. For the Azure CLI there are now (as of at least June 2022) commands for managing Logic Apps, both of the "standard" and "consumption" varieties.
For "standard" Logic Apps you can manage them with the az logicapp command. E.g.:
az logicapp list --resource-group MyResourceGroup
For all the operations, run az logicapp --help.
For "consumption" Logic Apps, there is a (currently in preview) command of az logic workflow that requires a logic extension to be installed for the Azure CLI. E.g.:
az logic workflow list --resource-group MyResourceGroup
For all the operations, run az logic workflow --help.
#4c74356b41's answer is definitely still valid, but better support for managing Logic Apps is now a part of the Azure CLI (which is also not directly tied to PowerShell as indicated by the OP's question...the Azure CLI does not have to be run in PowerShell).
See Microsoft's official docs for these Azure CLI commands (and others) at:
Standard Logic Apps
Consumption Logic Apps
the AZ cli equivalent of Get-AzLogicApp is the following:
az resource list --resource-type 'Microsoft.Logic/workflows'
there are no dedicated cmdlets for managing logic apps in Az cli yet.
You could use below method to get logic app list.
Get-AzResource -ResourceType "Microsoft.Logic/workflows" -ResourceGroupName resourcegroupname
As for the sqlservers and sqldatabase, you could just use the method provided.
Get-AzSqlDatabase and Get-AzSqlServer support to list the servers and the databases.

Add Application Insights to an azure function with Azure CLI

I have a PowerShell script which creates an azure function app on a consumption plan and its associated storage account within a resource group using the azure cli following the example In the Microsoft Docs
However to enable application insights I have to go to the azure portal, find the func select monitor and click enable application insights.
How can I expand that script to enable automate this step for the newly created function? I have been unable to find any specific documentation or examples and I would prefer to avoid resource templates if possible.
OF course, you could enable Application Insights to the azure function by Azure CLI.
But you need to create the Application Insights in the portal first, currently, it is unable to create Application Insights via Azure CLI.
You could follow the steps below.
1.Go to your Application Insights in the portal, copy the Instrumentation Key in the screenshot.
2.After creating the function app by your command , just use the CLI command below.
az functionapp config appsettings set --name <functionname> --resource-group <resourcegroupname> --settings 'APPINSIGHTS_INSTRUMENTATIONKEY = <Instrumentation Key>'
It works fine on my side, you could check it in the portal.

Resources