I have 2 different function apps and deployment scripts. The first app (functionApp1) uses the az cli, and the second one is being written to use the new AZ Powershell modules.
I thought I wouldn't be impacting the az cli solution by installing/setting up the latest powershell cmdlets but I think functionApp1's deployment is broken since installing the new Az Powershell tools.
When I run the az cli deployment script for function App 1, it dies while trying to publish the application. The error message says:
You're trying to use v4 tooling to publish to a non-v4 function app
(FUNCTIONS_EXTENSION_VERSION is set to ~3). You can pass --force to
force update the app to v4, or downgrade tooling for publishing.
Code
In case it helps, here are some snippets of code from the deployment script for functionApp1 The following logic to create a resource group, application insights, and a storage account all works:
az login --service-principal --username $CLIENT_ID --password $SECRET --tenant $TENANT --allow-no-subscriptions
az account set --subscription $SUBSCRIPTION_ID
az group create -n $RESOURCE_GROUP_NAME -l $RESOURCE_LOCATION
az deployment group create --resource-group $RESOURCE_GROUP_NAME --template-file (Join-Path $PSScriptRoot "./resources/function1App.json")
Next I grab information from the new resources I created above, and I update my local.settings.json file. This also still works:
func settings add FUNCTIONS_WORKER_RUNTIME dotnet #explicitly set this.
#auto-update the local.settings.json file with connection string
func azure storage fetch-connection-string $storageAccount.name
#grab contents of local settings file.
$data = Get-Content 'local.settings.json' -raw | ConvertFrom-Json
#logic to update local settings.
Lastly I try to publish the functions in azure using my local settings file. And this is the part that is no longer working:
$functionDeploymentResult = func azure functionapp publish $FUNCTION_APP.name --publish-local-settings -i --overwrite-settings -y
But the error message I'm getting is this:
You're trying to use v4 tooling to publish to a non-v4 function app (FUNCTIONS_EXTENSION_VERSION is set to ~3).
You can pass --force to force update the app to v4, or downgrade tooling for publishing.
I tried to add the --force option and while it gets rid of the error message, when I try to actually run my test "hello world" function in azure, I see the following error message:
Microsoft.Azure.WebJobs.Script: One or more loaded extensions do not meet the minimum requirements. For more information see https://aka.ms/func-min-extension-versions.
ExtensionStartupType AzureStorageWebJobsStartup from assembly 'Microsoft.Azure.WebJobs.Extensions.Storage, Version=4.0.3.0, Culture=neutral, PublicKeyToken=asdfasdfasdf' does not meet the required minimum version of 4.0.4.0. Update your NuGet package reference for Microsoft.Azure.WebJobs.Extensions.Storage to 4.0.4 or later.
AZ CLI VERSION
PS C:\Users\me\Documents\src\functionapp1> az --version
azure-cli 2.30.0 *
core 2.30.0 *
telemetry 1.0.6
Python location 'C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\python.exe'
Extensions directory 'C:\Users\me\.azure\cliextensions'
Python (Windows) 3.8.9 (tags/v3.8.9:a743f81, Apr 6 2021, 13:22:56) [MSC v.1928 32 bit (Intel)]
Legal docs and information: aka.ms/AzureCliLegal
You have 2 updates available. Consider updating your CLI installation with 'az upgrade'
Please let us know how we are doing: https://aka.ms/azureclihats
and let us know if you're interested in trying out our newest features: https://aka.ms/CLIUXstudy
.vscode/settings.json
{
"azureFunctions.deploySubpath": "src/bin/Release/netcoreapp3.1/publish",
"azureFunctions.projectLanguage": "C#",
"azureFunctions.projectRuntime": "~3",
"debug.internalConsoleOptions": "neverOpen",
"azureFunctions.preDeployTask": "publish (functions)"
}
I'm presently trying to do some research on how / what specifically to downgrade but any tips / suggestions would be appreciated.
Azure PowerShell does not interfere with Azure cli installation.
Based on the error message, it looks like the version of the Azure function tools you are using is v4 but the function app that you have deployed is v3 (likely defined so in the ARM template that you are using).
Related
I am using Azure CLI to use the azure. I am trying to create a staticwebapp and later try to add the configuration from CLI.
I tried to run this
az staticwebapp appsettings set -n appname --setting-names MONGO_CONNECTION_STRING="mongodb+srv://anirudha:testing#cluster4340.v45343.mongodb.net/?retryWrites=true&w=majority"
I am getting error
'w' is not recognized as an internal or external command,
operable program or batch file.
I go to portal and seen before &w=majority is added into configuration but this part is not added after &.
I tried to put singlequote and key=("val") but none of them working for me. I found this in azure app config github repo.
Anyone have idea how to make it work from CLI
--setting-names property accepts the app settings in 'key=value' format as mentioned here in this documentation of az staticwebapp app settings set cmdlet.
You need to change the above shared cmdlet to the below:
az staticwebapp appsettings set -n <staticWebAppName> --setting-names 'MONGO_CONNECTION_STRING=<AppsettingValue>'
I have tested this and it is working fine from my end Here is the sample output screenshot for your reference:
Updated Answer:
Alternatively, you can use this PowerShell cmdlet
(New-AzStaticWebAppSetting) to update the app settings of the static web app
New-AzStaticWebAppSetting -ResourceGroupName resourceGroup -Name staticweb01 -AppSetting #{'function01' = 'value01'; 'function02' = 'value02' }
I tried different ways to deploy my local logic app from VS Community using powershell but none of them are working.
Any solutions for this?
Logic App deployment successful from Visual Studio (local) through PowerShell Command
The following command worked for me
New-AzResourceGroupDeployment -ResourceGroupName <Azure-resource-group-name> -TemplateUri https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/quickstarts/microsoft.logic/logic-app-create/azuredeploy.json
and here is the output:
Here is the process that I followed before running the above command.
Process Flow:
I have found that there are 2 ways of deploying logic app through PowerShell i.e., Azure RM Template Commands and AZ Modules Commands
To work with any of the following commands, we are required to install related package files:
To deploy using Azure RM Template Commands - Run this code on PowerShell:
Install-Module -Name AzureRM -AllowClobber
To deploy using AZ module commands - Run this code on PowerShell:
Install-Module -Name Az -Scope CurrentUser -Repository PSGallery -Force
Checkout the following links to play with versions (uninstalling old and installing new), setting up the policies, connecting of Azure Accounts, etc in these:
Azure RM PowerShell Commands and Azure Az Module PowerShell Commands
Following is the process of which I have tried deploying the Local Visual Studio Logic App to Azure in PowerShell using Azure RM PowerShell Script commands:
Before deploying:
Create a Logic App in Visual Studio (File > New Project > Select 'Azure Resource Group' > Logic App)
Your solution will be ready in a few seconds, you will be able to see two json files. As you select prameters.json file you will be able to see json schema for logic app deployment.
To Connect your logic with your Azure Account, right click on LogicApp.json and select 'Open with logic app designer'. If you don't find this option, then install this extension in your project:
Right click on project and click on validate
Select your resource group, subscription and click on edit parameters - give custom name to your logic app. Otherwise, it will throw you error of null in logicAppName and shows template is invalid.
After validation, it shows the template is valid. It can be automatically validate during deployment process also, but it's good way to validate to get rid out of errors.
PowerShell Commands to deploy your logic App from visual studio (local):
Install this Power Shell provided by Microsoft Cloud.
Run in Administrator Mode > Login with Connect-AzureRmAccount command (it takes you to browser and connect with Azure account) > after that it imports your subscription and resource group details in the shell like below:
Use the following command to deploy your logic app
New-AzResourceGroupDeployment -ResourceGroupName "AzureAccountMail" -Templatefile "C:\LogicAppTemplats\template.json" -TemplateParameterFile "C:\LogicAppTemplats\parameters.json"
Check this following documentation for this command overview.
Done! Deployment Succeeded.
Now Check out in the azure portal:
Note:
Here you can find the template file and parameters.json file under your project:
Make Sure you given your logic app name value here in the parameters.json file:
And Provide the logic app name, deployment location values in the template.json file (LogicApp.json)
When I try to deploy an Azure Function to the cloud using... func azure functionapp publish appName --build remote --publish-local-settings
...I receive the following error
Getting site publishing info...
Remote build is a new feature added to function apps.
Your function app appName does not support remote build as it was created before August 1st, 2019.
Please use '--build local' or '--build-native-deps'.
For more information, please visit https://aka.ms/remotebuild
EVEN THOUGH THE APP WAS LITERALLY JUST CREATED IN AZURE PORTAL.
System:
- Running VS Code on Ubuntu 18.04
Steps to reproduce:
Create a new Function App (and support resources) using az cli
Python runtime
Consumption plan
StandardV2 Storage plan
AppInsights
Create new Function (scaffolding) using VS Code Azure Functions extension
Create __init__.py and configure local.settings.json
Open a terminal; cd to Function folder
Run func azure functionapp publish appName --build remote --publish-local-settings
Fails everytime with the message above
Tried so far:
- Substituting --build local.
- Looks like it wants to work, but fails with error
There was an error restoring dependencies. ERROR: cannot install cryptography-2.9.2 dependency: binary dependencies without wheels are not supported when building locally. Use the "--build remote" option to build dependencies on the Azure Functions build server, or "--build-native-deps" option to automatically build and configure the dependencies using a Docker container. More information at https://aka.ms/func-python-publish
Not going to try:
- --build-local-deps because I don't want a docker instance for my Function App
Please advise. This is painful at this point.
In my case, I was provisioning an azurerm_linux_function_app with terraform and got this error. The error turned out to be caused by me forgetting to specify the storage_account_access_key setting. The docs even mention
One of storage_account_access_key or storage_uses_managed_identity must be specified when using storage_account_name.
But terraform does not actually check that when applying your configuration, resulting in a cryptic error message much later in the process.
Here is what was found today:
I initially created the Function App Storage Account with...
# Create a Function App Storage Account
az storage account create \
--name $fa_storage_name \
--resource-group $rg_name \
--access-tier Cool \
--default-action Deny \
--kind StorageV2 \
--subscription $az_sub
--location $az_loc \
--sku Standard_LRS
Changed this to...
# Create a Function App Storage Account
az storage account create \
--name $fa_storage_name \
--resource-group $rg_name \
--location $az_loc \
--sku Standard_LRS
...and was able to get past that error. The way I stumbled onto this was using the --buld local flag. It gave me a MUCH MORE ACCURATE error. Something along the lines of Check your storage account dude.
(thank you Marcelo!)
I get this error in windows CMD "stat: path too long for Windows" whenever I execute this command below in my azure cli in windows CMD.
az group deployment create -g "testacsengine" --template-file azuredeploy.json --parameters #azuredeploy.parameters.json
In windows, if you already install the Azure CLI model, you can execute the CLI command in CMD or Windows PowerShell ISE.
For the deployment of Azure template, you can just use the command az group deployment create -g "charlesTest" --template-file template.json in the directory of your template.
Or use the absolute path like this az group deployment create -g "charlesTest" --template-file D:\template.json. Of curse, you need to get authentication with the command az login first.
If you still get the error when you do this, the error must be inside your template. You should check your template correctly.
For more details about template deployment, see az group deployment create.
The following command is based on a code snippet I found in the official documentation to create a Linux Service Fabric cluster.
Originally it was bash script, but that's not available on my private build agents (requires windows insider program??) so I switched to batch script.
I wonder why the following command fails:
d:\a\r1\a>call az sf cluster create --resource-group "ha17aztestclustergroup" --location "westeurope" --certificate-output-folder . --certificate-password "433q6D7sdNKkd-.,6ck#6" --certificate-subject-name "ha17rsomaztestsf.cloudapp.azure.com" --cluster-name "ha17aztestcluster" --cluster-size 3 --os UbuntuServer1604 --vault-name "ha17rsomaztestkeyvault" --vault-resource-group "ha17aztestclustergroup" --vm-password $VmPassword --vm-user-name "sfadmin"
ERROR: az sf cluster: error: argument subcommand: invalid choice: create
usage: az sf cluster [-h]
{select,manifest,code-version,config-version,health} ...
The exact same inline script does work on my private build agents with AZ CLI 2.0.20 installed.
Azure hosted Agents (VS2017) has AZ CLI 2.0.14 installed.
But I doubt that's the problem.
The Hosted VS2017 has Azure CLI 2.0.14 installed, there isn’t create command for az sf cluster (2.0.21 contains), you can check it by adding Azure CLI task with az sf cluster --help command to check its commands.
So, you can setup a private build agent and do build with this agent. Deploy an agent on Windows
I ran into a similar problem whilst deploying a different resource (Function Apps). There was a bug fix in a later version than what was installed on the hosted agents.
I ended up getting around this problem by either dynamically injecting this command into my scripts or by simply having an extra Azure CLI step in my Release to update Azure CLI
pip install --pre azure-cli --extra-index-url https://azurecliprod.blob.core.windows.net/edge
Unfortunately it takes nearly 5 minutes to update the Agent but all of my Releases are reliable now.