Azure functions on Premises - Error response from daemon: Cannot kill container
I am working with Azure Functions on Premises V2 (Runtime). Trying to test a simple function that is executed each minute and write in logs. However Function is not executed, and I am getting this error. It is running on a Virtual Machine with Windows server 2016. (what I think could be causing this problem). I am new wiht Docker and Hyper-V, any help will be appreciated. There are some command lets I can execute, to comprobate if Hyper V and Docker are running well ?
Thank You in Advance.
This is the Log I'm getting:
3/14/2018 5:42:44 PM Welcome, you are now connected to log-streaming service.3/14/2018 5:41:48 PM [myteslaVM] Function App 'MyContainerFuncApp' is starting.. 3/14/2018 5:41:49 PM [myteslaVM] Pull container image azfuncrun/azure-functions-runtime:preview2-latest-nanoserver3/14/2018 5:41:50 PM [myteslaVM] preview2-latest-nanoserver: Pulling from azfuncrun/azure-functions-runtime3/14/2018 5:41:50 PM [myteslaVM] Digest: sha256:dfdb47a7638d0cdd1a42c603e3e59311ee0d229222f88329a7c561fc3d8b2ff33/14/2018 5:41:50 PM [myteslaVM] Status: Image is up to date for azfuncrun/azure-functions-runtime:preview2-latest-nanoserver
3/14/2018 5:41:50 PM [myteslaVM] The container image azfuncrun/azure-functions-runtime:preview2-latest-nanoserver has been pulled successfully! 3/14/2018 5:41:50 PM [myteslaVM] Provisioning container MyContainerFuncApp_
03/14/2018 5:41:51 PM [myteslaVM] f2788b6c9c5d6115bba891f463759dd0df75c2344e6c217b0280a8b9f686fb32 3/14/2018 5:41:51 PM [myteslaVM] C:\Program Files\Azure Functions Runtime\docker\docker.exe: Error response from daemon: container f2788b6c9c5d6115bba891f463759dd0df75c2344e6c217b0280a8b9f686fb32 encountered an error during CreateContainer: failure in a Windows system call: No hypervisor is present on this system. (0xc0351000) extra info: {"SystemType":"Container","Name":"f2788b6c9c5d6115bba891f463759dd0df75c2344e6c217b0280a8b9f686fb32","Owner":"docker","IgnoreFlushesDuringBoot":true,"LayerFolderPath":"C:\Program Files\Azure Functions Runtime\docker\windows\windowsfilter\f2788b6c9c5d6115bba891f463759dd0df75c2344e6c217b0280a8b9f686fb32","Layers":[{"ID":"951f96e7-ad8c-5e5c-8533-4f70d49a4e6a","Path":"C:\Program Files\Azure Functions "HostName":"f2788b6c9c5d","MappedDirectories":[{"HostPath":"c:\windows\temp\fwas\mycontainerfuncapp","ContainerPath":"c:\home","ReadOnly":false,"BandwidthMaximum":0,"IOPSMaximum":0,"CreateInUtilityVM":false}],"HvPartition":true,"EndpointList":["d6c4c527-5520-40f1-9c84-2f3d8a013900"],"HvRuntime":{"ImagePath":"C:\Program Files\Azure Functions Runtime\docker\windows\windowsfilter\545c1be2ad30f1933a07de48e4ffe611900bacafbf4b717de969b56fb8a725d6\UtilityVM"},"AllowUnqualifiedDNSQuery":true}.
3/14/2018 5:41:51 PM [myteslaVM] Issuing stop command to container: MyContainerFuncApp_
03/14/2018 5:41:52 PM [myteslaVM] Error response from daemon: Cannot kill container: MyContainerFuncApp_0: No such container: MyContainerFuncApp_03/14/2018 5:41:52 PM [myteslaVM] Stop complete for container: MyContainerFuncApp_03/14/2018 5:41:52 PM [myteslaVM] ExecuteCommand called with C:\Program Files\Azure Functions Runtime\docker\docker.exe returned 125.3/14/2018 5:42:03 PM [myteslaVM]
Function App 'MyContainerFuncApp' is starting...3/14/2018 5:42:04 PM [myteslaVM] Pull container image azfuncrun/azure-functions-runtime:preview2-latest-nanoserver3/14/2018 5:42:06 PM [myteslaVM] preview2-latest-nanoserver: Pulling from azfuncrun/azure-functions-runtime3/14/2018 5:42:06 PM [myteslaVM] Digest: sha256:dfdb47a7638d0cdd1a42c603e3e59311ee0d229222f88329a7c561fc3d8b2ff3
3/14/2018 5:42:06 PM [myteslaVM] Status: Image is up to date for azfuncrun/azure-functions-runtime:preview2-latest-nanoserver3/14/2018 5:42:06 PM [myteslaVM] The container image azfuncrun/azure-functions-runtime:preview2-latest-nanoserver has been pulled successfully!3/14/2018 5:42:06 PM [myteslaVM] Provisioning container MyContainerFuncApp_13/14/2018 5:42:07 PM [myteslaVM] 10dfbab15acef64780c34d5d01ded776a10d074500b33ba916b032920404d1d13/14/2018 5:42:07 PM [myteslaVM] C:\Program Files\Azure Functions Runtime\docker\docker.exe:
After some research I did next steps in order to try to resolve this error.
1.Windows Server 2016 Configuration
https://app.pluralsight.com/player?course=installing-windows-server-2016&author=greg-shields&name=installing-windows-server-2016-m2&clip=5&mode=live
--Install Features and Roles.
2.Install Hyper-V
https://docs.microsoft.com/en-us/windows-server/virtualization/hyper-v/get-started/install-the-hyper-v-role-on-windows-server
To check Hyper-V installed, run this cmd let in Power Shell.
Get-WindowsFeature -ComputerName <computer_name>
Get-WindowsFeature -ComputerName MyteslaVM
To Install Hyper-V
Add-WindowsFeature –name RSAT-Hyper-V-Tools
https://social.technet.microsoft.com/Forums/windows/en-US/f750d5e3-69f8-4cbd-a7aa-98e2fd41c618/need-to-install-hyperv-management-tools-on-server-2012-vm?forum=winserverhyperv
3.Execute Docker version.
4.Execute Dockerd "Daemon" .
https://www.bountysource.com/issues/40602674-can-t-start-docker-service-on-windows-server-vm
dockerd --debug
Stop-service docker
Get-ContainerNetwork | Remove-ContainerNetwork -Force
Start-service docker
5. Get-VM | Set-VMProcessor -ExposeVirtualizationExtensions $true
https://github.com/Azure/Azure-Functions/issues/359
6.Install Docker
https://docs.microsoft.com/en-us/virtualization/windowscontainers/quick-start/quick-start-windows-server
Install-Module -Name DockerMsftProvider -RequiredVersion 1.0.0.3
Install-Module -Name DockerMsftProvider -Repository PSGallery -Force
Install-Package -Name docker -ProviderName DockerMsftProvider
7.Install The latest azure-functions-core-tools:
npm i -g azure-functions-core-tools@core
Run npm i -g npm **to update
-
Install .NET Core 2.0
https://www.microsoft.com/net/download/windows
9.To enable nested virtualization, you need to run the following cmdlet in the Hyper-V host:
Get-VM | Set-VMProcessor -ExposeVirtualizationExtensions $true
10.Run Script
https://github.com/moby/moby/issues/19685
11.Download azure-functions-runtime:2.0.0-nanoserver
docker pull microsoft/azure-functions-runtime:2.0.0-nanoserver-1709
12.One of the Hyper-V components is not running
https://social.technet.microsoft.com/Forums/en-US/b4d0761d-6048-4cb8-9a1f-1a2544b4ceb2/one-of-the-hyperv-components-is-not-running?forum=win10itprovirt
13.Disable Windows defender.
https://www.windowscentral.com/how-permanently-disable-windows-defender-windows-10
However I still getting same error, I went to to check at Event Viewer.
Start-->ComputerManagment-->Event Viwer
Click on Errors for AzureFunctionsDockerDaemonForWindows
Error is :
Handler for POST /v1.33/containers/create returned error: Cannot create layer with missing parent 21d15d67395fcae039a1eecd64433db2a351ab5a60f326b8f51e25687fa4a990: GetFileAttributesEx C:\Program Files\Azure Functions Runtime\docker\windows\windowsfilter\21d15d67395fcae039a1eecd64433db2a351ab5a60f326b8f51e25687fa4a990: The system cannot find the file specified.
/cc @jhowardmsft @powersplay @taylorb-microsoft @StefanScherer
Any help will be appreciated, Thank You!
It seems that some layers of the image are not present. Please open a command prompt as administrator and run the following: SET PATH=%PATH%;%ProgramW6432%\Azure Functions Runtime\docker SET DOCKER_HOST=npipe:////./pipe//docker_azure_functions_windows
Then, you can use the regular docker commands to troubleshoot like: docker images
I recommend, to delete all existing images: docker rmi --help
Thank You @jvano for Your comment.
Actually Docker is running and I have not problems to execute commands direct on docker.
docker version docker info docker ps -a docker images.
This Error is showed on Azure Functions Runtime component, and is same error I get on Event Viewer.
As part of the "Azure Functions Runtime" installer, we install a new dockerd service which listens on a different pipe, that's why I asked you to point the DOCKER_HOST to npipe:////./pipe//docker_azure_functions_windows.
I think we should delete all images and let the "Azure Functions Runtime" pull them back again. Hopefully, this will solve the issue.
It seems as Azuer Function runtime component is not working for Windows Server 2016, because containers.
I tried it with a new Virtual Machine, with Windows 10 Pro. And it is now working. Steps: 1)Create Virtual Machine, with Windows 10 Pro 2)Install/enable Hyper-V 3)Install and configure Component for Azure Functions.

Sorry, looking at your logs again it says: "No hypervisor is present on this system. (0xc0351000)" Most likely you are running this in a VM and you need to enable nested virtualization to run Hyper-V containers inside a VM.
You can enable nested virtualization to your Functions Workers by running the following command in the Hyper-V host:
Get-VM | Set-VMProcessor -ExposeVirtualizationExtensions $true
Researching more on the subject, I realized that it does not work for Basic Plan (SKU) for virtual Machines.
Only works for SKU in Standard plan.
Applies for both Windows Pro and Windows Server 2016.

Yes, if you are running this on Azure, nested virtualization is supported in the Dv3 and Ev3 series of Azure virtual machines.
For more info: https://azure.microsoft.com/en-us/blog/nested-virtualization-in-azure/
@jvano
doubt..
What are real use cases for Azure Functions on Prem?
What is the right purpose, for which it was created?
The idea is enable people to use the same programming model for even-driven workloads on-premises and in the cloud while also enabling interesting hybrid cloud scenarios.
Thank you, for clarification.