Closed andygjp closed 1 year ago
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @ahmedelnably, @fabiocav.
Author: | andygjp |
---|---|
Assignees: | - |
Labels: | `Service Attention`, `Functions`, `customer-reported` |
Milestone: | - |
route to service team
Hi,
Is anyone looking into this?
Or alternatively, is there a way to build an isolated process function and deploy it to a Linux based App Service plan (I need Hybrid Connection)? The Windows based App Service plan is almost £40 more expensive than the equivalent Linux plan!
@FinVamp1 what is the best way here to figure out the cause of failure of zip deployment?
@andygjp is the deployment you are trying on a newly created Linux app? The failure could be due to difference in runtime/ language versions b/w windows & Line apps.
Hello, @andygjp if you wanted to send me an app name and time frame to finbar.ryan at microsoft.com then I can check out to see why this might fail. I can look at this tomorrow.
Hi @FinVamp1 ,
I apologise for my tardy response - I've been really busy with other things. I have sent you an email with the requested details.
I've included my Azure pipeline file - you can take a look at the az
commands I'm using
trigger:
- main
variables:
azureSubscription: '<reference your service connection>'
stages:
- stage: build
pool:
vmImage: windows-2022
jobs:
- job:
displayName: Create build artefact
steps:
- checkout: self
- task: Bash@3
displayName: Build
inputs:
targetType: inline
script: |
dotnet publish --self-contained true \
--runtime linux-x64 \
--output ./output/Caller \
./Caller/Caller.csproj
dotnet publish --self-contained true \
--runtime linux-x64 \
--output ./output/Callee \
./Callee/Callee.csproj
- task: PowerShell@2
displayName: Archive
inputs:
targetType: 'inline'
script: |
# Include hidden folders
Get-ChildItem -Path ./output/Caller/ -Force `
| Compress-Archive -DestinationPath ./output/Caller.zip
Compress-Archive -Path ./output/Callee/* `
-DestinationPath ./output/Callee.zip
- publish: ./output/Callee.zip
artifact: Callee
displayName: Publish Callee.zip
- publish: ./output/Caller.zip
artifact: Caller
displayName: Publish Caller.zip
- stage: deploy
pool:
vmImage: windows-2022
jobs:
- job: createCallee
displayName: Create Callee WebApp
steps:
- checkout: none
- download: current
artifact: Callee
- task: AzureCLI@2
displayName: Create or update web app infrastructure
inputs:
azureSubscription: $(azureSubscription)
scriptType: pscore
scriptLocation: inlineScript
inlineScript: |
$resourceName = "<name this whatever you like>"
$resourceLocation = "UK South"
$servicePlanSku = "B1"
"create resource group '$resourceName' in '$resourceLocation'"
az group create --name $resourceName --location $resourceLocation
"create '$servicePlanSku' service plan '$resourceName'"
az appservice plan create --name $resourceName `
--resource-group $resourceName `
--sku $servicePlanSku `
--is-linux
"create '$resourceName' web app"
az webapp create --name $resourceName `
--resource-group $resourceName `
--plan $resourceName `
--https-only true `
--runtime "DOTNETCORE:6.0"
"update '$resourceName' web app config"
az webapp config set --name $resourceName `
--resource-group $resourceName `
--http20-enabled true `
--min-tls-version 1.2 `
--ftps-state Disabled `
--always-on true
"set source"
az webapp deployment source config-zip --name $resourceName `
--resource-group $resourceName `
--src $(Pipeline.Workspace)/Callee/Callee.zip `
--timeout 300
- job:
displayName: Create Caller Func
dependsOn: createCallee
steps:
- checkout: none
- download: current
artifact: Caller
- task: AzureCLI@2
displayName: Create or update function infrastructure
inputs:
azureSubscription: $(azureSubscription)
scriptType: pscore
scriptLocation: inlineScript
inlineScript: |
$resourceName = "<name this whatever you like>"
$resourceLocation = "UK South"
$storageResource = "<name this whatever you like>"
$pause = 30
$servicePlanSku = "B1"
"create resource group '$resourceName' in '$resourceLocation'"
az group create --name $resourceName --location $resourceLocation
"create storage account '$storageResource' in '$resourceLocation'"
az storage account create --name $storageResource `
--location $resourceLocation `
--resource-group $resourceName `
--sku Standard_LRS `
--allow-blob-public-access false `
--https-only true `
--min-tls-version TLS1_2 `
--kind StorageV2
"create appservice plan '$resourceName' in '$resourceLocation'"
az functionapp plan create --name $resourceName `
--resource-group $resourceName `
--sku $servicePlanSku `
--is-linux
"check if function '$resourceName' exists"
$funcExists = az functionapp list --resource-group $resourceName `
--query "contains([].name, '$resourceName')"
if ($funcExists -eq $true) {
"function exists"
} else {
"function does not exist, creating now"
az functionapp create --name $resourceName `
--resource-group $resourceName `
--storage-account $storageResource `
--plan $resourceName `
--disable-app-insights false `
--functions-version 4 `
--runtime dotnet
}
"update function '$resourceName'"
az functionapp update --name $resourceName `
--resource-group $resourceName `
--set httpsOnly=true
"update '$resourceName' web app config"
az functionapp config set --name $resourceName `
--resource-group $resourceName `
--http20-enabled true `
--min-tls-version 1.2 `
--ftps-state Disabled `
--net-framework-version v6.0 `
--always-on true
"set app settings"
az functionapp config appsettings set --name $resourceName `
--resource-group $resourceName `
--settings "FUNCTIONS_WORKER_RUNTIME=dotnet-isolated" "WEBSITE_RUN_FROM_PACKAGE=0"
"stop the function app to workaround deployment issues"
# https://github.com/Azure/azure-cli/issues/13655
az functionapp stop --name $resourceName --resource-group $resourceName
"pause for $pause s to allow the function to stop"
Start-Sleep -s $pause
"set deployment source"
az functionapp deployment source config-zip --name $resourceName `
--resource-group $resourceName `
--src $(Pipeline.Workspace)/Caller/Caller.zip `
--timeout 300 `
--debug
$result=$?
if ($result -eq $true) {
"function source updated"
} else {
"function source not updated"
exit 1
}
"start the function app"
az functionapp start --name $resourceName --resource-group $resourceName
I did manage to get it to deploy without az functionapp deployment source config-zip
returning an error, but only when WEBSITE_RUN_FROM_PACKAGE=0
was changed to WEBSITE_RUN_FROM_PACKAGE=1
. However, that meant that functions were missing - I got a 404 when I browsed the expected endpoint.
This SO post pointed out that they can deploy successfully when they used Visual Studio. I also can deploy successfully using the publish functionality of Rider. I don't know what command it is using to publish the code.
Hello,
I looked and I think you don't need to build this a self contained application. dotnet publish --self-contained true .
Most of our examples build it like this.
- task: DotNetCoreCLI@2
displayName: Build My Project
inputs:
command: 'build'
projects: '**/*.csproj'
arguments: '--output $(build.artifactstagingdirectory)/Ramp.AksFunc/publish_output --configuration $(BuildConfiguration)'
I can see the zip file reach the Function app but then log errors like ths,
ExitCode: 1, Output: Handling Basic Web Site deployment. Kudu sync from: '/tmp/zipdeploy/extracted' to: '/home/site/wwwroot' Copying file: '.azurefunctions\Microsoft.Azure.Functions.Worker.Extensions.dll' Copying file: '.azurefunctions\Microsoft.Azure.Functions.Worker.Extensions.pdb' Copying file: '.azurefunctions\Microsoft.Azure.WebJobs.Extensions.FunctionMetadataLoader.dll' Copying file: '.azurefunctions\Microsoft.Azure.WebJobs.Host.Storage.dll' Copying file: '.azurefunctions\Microsoft.WindowsAzure.Storage.dll' Error: EINVAL: invalid argument, open '/home/site/wwwroot/.azurefunctions\Microsoft.Azure.Functions.Worker.Extensions.dll' An error has occurred during web site deployment. Kudu Sync failed, Error: , Kudu.Core.Infrastructure.CommandLineException: /opt/Kudu/Scripts/starter.sh /home/site/deployments/tools/deploy.sh
at Kudu.Core.Infrastructure.Executable.ExecuteInternal(ITracer tracer, Func2 onWriteOutput, Func
2 onWriteError, Encoding encoding, String arguments, Object[] args)
at Kudu.Core.Infrastructure.Executable.ExecuteWithProgressWriter(ILogger logger, ITracer tracer, String arguments, Object[] args)
The source config-zip will use zip deploy to deploy the zip and if Run From Package isn't set then it will just copy that to /home/site/wwwroot.
If Run From Package is set then it will try and mount the zip to home/site/wwwroot but if this is built as a self contained app it may not have the folder structure we are expecting.
Hi,
I'm not sure if the problem is caused by the type of the built artefact.
I've created a repo, https://github.com/andygjp/LinuxAzureFuncSample, which deploys the same function to a Windows and Linux host via zip-deploy.
The output is generated in the same way:
dotnet publish --self-contained true --runtime linux-x64 --output ./output/Sample-Linux ./Sample/Sample.csproj
dotnet publish --self-contained true --runtime win-x64 --output ./output/Sample-Win ./Sample/Sample.csproj
The zip file is generated in the same way:
Get-ChildItem -Path ./output/Sample-Win/ -Force `
| Compress-Archive -DestinationPath ./output/Sample-Win-Full.zip
# Repeat, but for Linux
Get-ChildItem -Path ./output/Sample-Linux/ -Force `
| Compress-Archive -DestinationPath ./output/Sample-Linux-Full.zip
The az
commands to create the function is the same, except for this one difference:
az functionapp plan create --name $resourceName `
--resource-group $resourceName `
--sku $servicePlanSku `
--is-linux
In the end, the Windows version works:
But the Linux version doesn't complete:
DEBUG: urllib3.connectionpool: Starting new HTTPS connection (1): linux-func-carbon-432.scm.azurewebsites.net:443
DEBUG: urllib3.connectionpool: [https://linux-func-carbon-432.scm.azurewebsites.net:443](https://linux-func-carbon-432.scm.azurewebsites.net/) "POST /api/zipdeploy?isAsync=true HTTP/1.1" 503 19
WARNING: cli.azure.cli.command_modules.appservice.custom: Deployment endpoint responded with status code 503
DEBUG: cli.azure.cli.core.util: azure.cli.core.util.handle_exception is called with an exception:
DEBUG: cli.azure.cli.core.util: Traceback (most recent call last):
File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/cli.py", line 231, in invoke
File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 663, in execute
File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 726, in _run_jobs_serially
File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 697, in _run_job
File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 333, in __call__
File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/command_operation.py", line 121, in handler
File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/appservice/custom.py", line 524, in enable_zip_deploy_functionapp
File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/appservice/custom.py", line 578, in enable_zip_deploy
azure.cli.core.azclierror.AzureInternalError: An error occured during deployment. Status Code: 503, Details: Service Unavailable
ERROR: cli.azure.cli.core.azclierror: An error occured during deployment. Status Code: 503, Details: Service Unavailable
ERROR: az_command_data_logger: An error occured during deployment. Status Code: 503, Details: Service Unavailable
(It did complete sometimes, but the function didn't work.)
Please fork the repo, https://github.com/andygjp/LinuxAzureFuncSample, and then create an Azure Pipeline to test it out. You just have to specify your Azure subscription:
Hi, Experiencing same problem as andygjp described it. Just in my use case, I'm using consumption plan on windows machines with java 11.
Hi,
I tried it again today and it still doesn't work.
Here is the output from az webapp log deployment show
:
[
{
"details_url": null,
"id": "9de5af57-cdaa-4141-a758-134b0ad54389",
"log_time": "2022-11-09T19:51:42.4324084Z",
"message": "Updating submodules.",
"type": 0
},
{
"details_url": null,
"id": "e919d6a3-67f5-4c08-baae-77adabc00d1c",
"log_time": "2022-11-09T19:51:43.5356596Z",
"message": "Preparing deployment for commit id '59fa4046-5'.",
"type": 0
},
{
"details_url": null,
"id": "4494ca56-9518-420f-8207-9dd3cb27b5d0",
"log_time": "2022-11-09T19:51:43.8374504Z",
"message": "PreDeployment: context.CleanOutputPath False",
"type": 0
},
{
"details_url": null,
"id": "fda64436-1a5e-4911-b50b-45cf966efe1a",
"log_time": "2022-11-09T19:51:43.9526835Z",
"message": "PreDeployment: context.OutputPath /home/site/wwwroot",
"type": 0
},
{
"details_url": "https://test-kbupdateservice-tin-l.scm.azurewebsites.net/api/deployments/59fa4046-510f-4506-85a5-c10fc80c85a9/log/eab825a7-ad7a-4dc1-9583-640026593f49",
"id": "eab825a7-ad7a-4dc1-9583-640026593f49",
"log_time": "2022-11-09T19:51:44.0977591Z",
"message": "Generating deployment script.",
"type": 0
},
{
"details_url": "https://test-kbupdateservice-tin-l.scm.azurewebsites.net/api/deployments/59fa4046-510f-4506-85a5-c10fc80c85a9/log/136d2838-ba59-467a-a9d9-d4b716b03fe7",
"id": "136d2838-ba59-467a-a9d9-d4b716b03fe7",
"log_time": "2022-11-09T19:51:44.33877Z",
"message": "Running deployment command...",
"type": 2
},
{
"details_url": null,
"id": "0845a02c-542e-4562-9543-b007d7a6d17d",
"log_time": "2022-11-09T19:51:45.5725926Z",
"message": "Deployment Failed. deployer = Push-Deployer deploymentPath = Functions App ZipDeploy. Extract zip.",
"type": 0
}
]
I think I discovered why it doesn't work. You are creating the zip archive with PowerShell which doesn't work. If you create it via 7zip or the Windows build in Send to archive, the deployment works. This only applies to Linux Functions. On Windows Functions the PowerShell created zip file works. Maybe you could give this a try.
@fraanns I tried it and it didn't work. However, the az functionapp deployment source config-zip
completed without error this time, so it's getting closer. Thank you 🙇♂️
The archive that 7Zip generates is different.
The powershell commands I've used to generate the archive flatten the hierarchy:
Whereas 7Zip does not:
(Is it strange that the archive structure doesn't matter for Windows based functions?)
The output from az webapp log deployment show
looks like this:
[
{
"details_url": null,
"id": "39d2be87-0a6a-4bc4-b1de-90bf5de098f5",
"log_time": "2023-02-03T17:29:53.3879347Z",
"message": "Updating submodules.",
"type": 0
},
{
"details_url": null,
"id": "94b83df9-efc3-4201-a082-6a08ee2a7b19",
"log_time": "2023-02-03T17:29:54.5140437Z",
"message": "Preparing deployment for commit id 'eb3fb0e8-7'.",
"type": 0
},
{
"details_url": null,
"id": "24ee3d3b-54dd-434b-89f0-5144c24bd8d4",
"log_time": "2023-02-03T17:29:54.8447633Z",
"message": "PreDeployment: context.CleanOutputPath False",
"type": 0
},
{
"details_url": null,
"id": "9c363681-ec71-4301-8297-d916d847f4d9",
"log_time": "2023-02-03T17:29:55.0305713Z",
"message": "PreDeployment: context.OutputPath /home/site/wwwroot",
"type": 0
},
{
"details_url": "https://linux-func-carbon-432.scm.azurewebsites.net/api/deployments/eb3fb0e8-7ccc-45a9-b4d0-c35d52a78f10/log/d0cdc37b-bfba-4e8f-a75a-6883163b887b",
"id": "d0cdc37b-bfba-4e8f-a75a-6883163b887b",
"log_time": "2023-02-03T17:29:55.1583805Z",
"message": "Generating deployment script.",
"type": 0
},
{
"details_url": "https://linux-func-carbon-432.scm.azurewebsites.net/api/deployments/eb3fb0e8-7ccc-45a9-b4d0-c35d52a78f10/log/ebdeb259-29d4-418a-b401-5c4affab5da3",
"id": "ebdeb259-29d4-418a-b401-5c4affab5da3",
"log_time": "2023-02-03T17:29:55.3636426Z",
"message": "Running deployment command...",
"type": 0
},
{
"details_url": null,
"id": "73e6dafb-89b8-4fa2-aa70-6c6760a439eb",
"log_time": "2023-02-03T17:30:05.9438012Z",
"message": "Running post deployment command(s)...",
"type": 0
},
{
"details_url": null,
"id": "26987017-7600-46c1-b2a6-58685e8389e2",
"log_time": "2023-02-03T17:30:06.2644001Z",
"message": "Triggering recycle (preview mode disabled).",
"type": 0
},
{
"details_url": null,
"id": "c94956f9-5a08-47e8-aa69-72ca6a4e9244",
"log_time": "2023-02-03T17:30:06.6476723Z",
"message": "Deployment successful. deployer = Push-Deployer deploymentPath = Functions App ZipDeploy. Extract zip.",
"type": 0
}
]
But when you GET https://linux-func-carbon-432.azurewebsites.net/admin/functions
it returns an empty array - it completed, but didn't create the function:
Any ideas?
I managed to get it working. 7Zip puts the contents inside of a directory. I moved all the files from that directory and put them inside wwwroot and it worked. I just need to workout the correct command to use.
Its working!
Changed the 7zip command from:
7z a ./output/Sample-Linux-Seven.zip ./output/Sample-Linux/
To:
cd ./output/Sample-Linux
7z a ../Sample-Linux-Seven.zip .
It looks like Compress-Archive
has a bug that prevents it from compressing hidden files: https://github.com/PowerShell/Microsoft.PowerShell.Archive/issues/66. And as far as I can tell, the fix hasn't been released yet.
Thank you to @fraanns once again. I wouldn't have gotten this to work without your suggestion!
Glad you got it working 😊
This is autogenerated. Please review and update as needed.
Describe the bug
Command Name
az functionapp deployment source config-zip
Errors:
To Reproduce:
Steps to reproduce the behavior. Note that argument values have been redacted, as they may contain sensitive information.
az functionapp deployment source config-zip --name {} --resource-group {} --src {} --timeout {}
Expected Behavior
Environment Summary
Additional Context
Output from
az webapp log deployment show -n lin-func-test-config-zip -g lin-func-test-config-zip
:Hi,
I'm attempting to change my azure function from a Windows app service plan to a Linux app service plan one. The method of deployment is the same, but when I deploy to Linux function it fails.
Do Linux functions support config-zip deployment?