DEV Community

Tsuyoshi Ushio
Tsuyoshi Ushio

Posted on

Solves 0 function found on Azure Function - Linux Consumption plan

I encounter an issue related archive. I trip to Japan. I use a desktop machine in Seattle, however, now I'm using my old laptop. I replaced the laptop with the desktop as my main machine.

The behavior is, I use the same Azure Functions sample. I crone the repo, In this case, the app is Java. I build it with mvn clean package then I archive it to a zip file. like this.

# Create a zip file
$currentDir = pwd
$zipFile = join-path $currentDir sample-cold.zip

Compress-Archive -Path '.\target\azure-functions\sample\*' -DestinationPath $zipFile -Force
Enter fullscreen mode Exit fullscreen mode

I use the same logic and create an archive. However, the archive I created on my desktop works, but not for a zip from laptop.

When I test both archives, extract these, it looks the same. I move the archive to WSL2 and extract these with unzip. It looks the same. According to the Azure Functions Host log, it says

0 functions found
Enter fullscreen mode Exit fullscreen mode

It is the issue of the archive. I did docker exec and find the root cause. When I go to /home/site/wwwroot I found the files that is downloaded and extracted zip file.

root@658408192cc6:~/site/wwwroot# ls -l
total 57867
-rw-rw-r-- 1 app app      354 Dec 10 11:51 'HttpTrigger-Java\function.json'
-rw-rw-r-- 1 app app     5267 Dec 10 11:51  codeless-azure-function-Test-1.0-SNAPSHOT.jar
-rw-rw-r-- 1 app app       24 Dec 10 19:42  host.json
-rw-rw-r-- 1 app app   317195 Dec 10 11:51 'lib\FastInfoset-1.2.16.jar'
-rw-rw-r-- 1 app app    30035 Dec 10 11:51 'lib\accessors-smart-1.2.jar'
-rw-rw-r-- 1 app app    62983 Dec 10 11:51 'lib\activation-1.1.jar'
-rw-rw-r-- 1 app app    94485 Dec 10 11:51 'lib\adal4j-1.6.2.jar'
-rw-rw-r-- 1 app app    17079 Dec 10 11:51 'lib\adapter-rxjava-2.4.0.jar'
-rw-rw-r-- 1 app app   136324 Dec 10 11:51 'lib\aether-api-1.0.2.v20150114.jar'
-rw-rw-r-- 1 app app   172998 Dec 10 11:51 'lib\aether-impl-1.0.2.v20150114.jar'
-rw-rw-r-- 1 app app    30705 Dec 10 11:51 'lib\aether-spi-1.0.2.v20150114.jar'
Enter fullscreen mode Exit fullscreen mode

It is weird, It was not the directly.

Solution

I found the issue was Compress-Archive command let version. The version I had issue is

> $Host.Version

Major  Minor  Build  Revision
-----  -----  -----  --------
5      1      19041  610
Enter fullscreen mode Exit fullscreen mode

I update the version to

> $host.version

Major  Minor  Build  Revision
-----  -----  -----  --------
7      1      0      -1
Enter fullscreen mode Exit fullscreen mode

This version looks work. Now I can see the directory.

The problem of the extract zip only happens with Azure Functions Host. Probably it is because of the library on C#.

I can see several Compress-Archive command let issue with Linux.
Compress-Archive on linux creates zip files with no file permissions.

Happy coding with Azure Functions!

Top comments (0)