Reputation: 1078
I'm deploying to the Azure Function via yaml pipeline and VS Publish profile, but it's failing the deployment with below non-understandable error.
##[debug]getDeploymentLogs. Data: {"statusCode":200,"statusMessage":"OK","headers":{"content-length":"147","connection":"close","content-type":"application/json; charset=utf-8","date":"Fri, 11 Aug 2023 11:25:43 GMT","server":"Microsoft-IIS/10.0","cache-control":"no-cache","expires":"-1","pragma":"no-cache","x-ms-request-id":"<id>","x-aspnet-version":"4.0.30319","x-powered-by":"ASP.NET"},"body":[{"log_time":"2023-08-11T11:25:38.0464127Z","id":"<id>","message":"Fetching changes.","type":0,"details_url":null}]}
**Fetching changes.**
##[error]Failed to deploy web package to App Service.
##[debug]Processed: ##vso[task.issue type=error;]Failed to deploy web package to App Service.
##[warning]Can't find loc string for key: KuduStackTraceURL
##[debug]Processed: ##vso[task.issue type=warning;]Can't find loc string for key: KuduStackTraceURL
##[error]KuduStackTraceURL https://$<function-name>:***@<function-name>.scm.azurewebsites.net/api/vfs/LogFiles/kudu/trace
##[debug]Processed: ##vso[task.issue type=error;]KuduStackTraceURL https://$<function-name>:***@<function-name>.scm.azurewebsites.net/api/vfs/LogFiles/kudu/trace
##[debug]Deployment Failed with Error: Error: Package deployment using ZIP Deploy failed. Refer logs for more details.
##[debug]task result: Failed
##[error]Error: Package deployment using ZIP Deploy failed. Refer logs for more details.
Background - Previously it was working, but I have added ARM deployment for Function App Settings.
"name": "[concat(parameters('<function-name>'), '/', 'appsettings')]",
"type": "Microsoft.Web/sites/config",
"apiVersion": "2022-09-01",
"dependsOn": [
"[resourceId('Microsoft.Web/sites', parameters('<function-name>'))]"
],
"tags": {
"displayName": "azwenprd01-devtst-pos-if1101-2-func-AppConfig"
},
But it failed as I used dependsOn for Function App which I'm not deploying through ARM. I removed dependOn and then ARM template got deployed. After this step I have added FunctionDeployment in my yaml pipeline. But after that, Function deployment were failing which was working previously.
Also, I checked all the files on Kudu. I observed that the ZIP is getting deployed under '\data\SitePackages>' but not getting extracted to wwwroot folder. Also the packagename.txt conatians the older .zip name.
Not sure what's causing this issue. Can we do the clean redeploy to Azure Function ? Or how to forcefully deploy to Azure Function ?
WEBSITE_RUN_FROM_PACKAGE is set to 1.
Upvotes: 1
Views: 2446
Reputation: 326
i had a case where the access token had expired and the deploy failed in the way shown above. getting an actual and valid token set up cured it. (these error message is probably not that intuitive and also not that clearly leading to the root cause.)
Upvotes: 0
Reputation: 8195
You can refer my SO thread answer with the ARM code to deploy Function app.
{ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", "contentVersion": "1.0.0.0", "parameters": { "appName": { "defaultValue": "[concat('funtionapp-', uniqueString(resourceGroup().id))]", "type": "string", "metadata": { "description": "The name of the function app that you wish to create." } }, "sku": { "defaultValue": "S1", "type": "string", "metadata": { "description": "The pricing tier for the hosting plan." } }, "workerSize": { "defaultValue": "0", "allowedValues": [ "0", "1", "2" ], "type": "String", "metadata": { "description": "The instance size of the hosting plan (small, medium, or large)." } }, "storageAccountType": { "defaultValue": "Standard_LRS", "allowedValues": [ "Standard_LRS", "Standard_GRS", "Standard_ZRS", "Premium_LRS" ], "type": "string", "metadata": { "description": "Storage Account type" } }, "repoURL": { "defaultValue": "https://github.com/username/FunctionApp25", "type": "string", "metadata": { "description": "The URL for the GitHub repository that contains the project to deploy." } }, "branch": { "defaultValue": "master", "type": "string", "metadata": { "description": "The branch of the GitHub repository to use." } }, "location": { "defaultValue": "[resourceGroup().location]", "type": "string", "metadata": { "description": "Location for all resources." } } }, "variables": { "functionAppName": "[parameters('appName')]", "hostingPlanName": "[concat(parameters('appName'), '-plan')]", "storageAccountName": "[concat(uniquestring(resourceGroup().id), 'functions')]" }, "resources": [ { "type": "Microsoft.Storage/storageAccounts", "apiVersion": "2021-02-01", "name": "[variables('storageAccountName')]", "location": "[parameters('location')]", "sku": { "name": "[parameters('storageAccountType')]" }, "kind": "Storage" }, { "type": "Microsoft.Web/serverfarms", "apiVersion": "2020-12-01", "name": "[variables('hostingPlanName')]", "location": "[parameters('location')]", "sku": { "name": "[parameters('sku')]" }, "properties": { "workerSize": "[parameters('workerSize')]", "numberOfWorkers": 1 } }, { "type": "Microsoft.Web/sites", "apiVersion": "2020-12-01", "name": "[variables('functionAppName')]", "location": "[parameters('location')]", "dependsOn": [ "[resourceId('Microsoft.Web/serverfarms', variables('hostingPlanName'))]", "[resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName'))]" ], "kind": "functionapp", "properties": { "name": "[variables('functionAppName')]", "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('hostingPlanName'))]", "clientAffinityEnabled": false, "siteConfig": { "alwaysOn": true, "cors": { "allowedOrigins": [ "*" ] }, "appSettings": [ { "name": "FUNCTIONS_EXTENSION_VERSION", "value": "~1" }, { "name": "AzureWebJobsStorage", "value": "[concat('DefaultEndpointsProtocol=https;AccountName=',variables('storageAccountName'),';AccountKey=',listkeys(resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName')), '2019-06-01').keys[0].value,';')]" }, { "name": "AzureWebJobsDashboard", "value": "[concat('DefaultEndpointsProtocol=https;AccountName=',variables('storageAccountName'),';AccountKey=',listkeys(resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName')), '2019-06-01').keys[0].value,';')]" } ] } }, "resources": [ { "type": "sourcecontrols", "apiVersion": "2020-12-01", "name": "web", "dependsOn": [ "[resourceId('Microsoft.Web/Sites', variables('functionAppName'))]" ], "properties": { "RepoUrl": "[parameters('repoURL')]", "branch": "[parameters('branch')]", "IsManualIntegration": true } } ] } ] }
My YAML pipeline:-
trigger:
- main
pool:
vmImage: ubuntu-latest
steps:
- task: AzureResourceManagerTemplateDeployment@3
displayName: 'ARM Template deployment: Resource Group scope'
inputs:
deploymentScope: 'Resource Group'
azureResourceManagerConnection: 'subscriptionid'
subscriptionId: 'xxxxxb4fd-e2b6e97cb2a7'
action: 'Create Or Update Resource Group'
resourceGroupName: 'rgname'
location: 'Australia East'
templateLocation: 'Linked artifact'
csmFile: '$(System.DefaultWorkingDirectory)/functionapp.json'
deploymentMode: 'Incremental'
YAML pipeline Output:-
Portal:-
My release pipeline output:-
Portal:-
Upvotes: 0