Azure-functions-core-tools: func.ps1 is not digitally signed. You cannot run this script on the current system.

Created on 12 Feb 2020  路  11Comments  路  Source: Azure/azure-functions-core-tools

_originally filed by @hdd42 in https://github.com/microsoft/vscode-azurefunctions/issues/1888_

Hi, I'm trying to run/test my function locally through vs code. I've installed azure function core tools@3 via npm the function I'm trying to test is a timer function.

Both hitting F5 to start debug mode or func host start from terminal failing and getting this error :

func.ps1 cannot be loaded. The file C:\Program Files\nodejs\func.ps1 is not
digitally signed. You cannot run this script on the current system.

looks like it complains about PowerShells Execution_Policies . I've removed azure function core tools and re-install it via choco install azure-functions-core-tools and host is starting without any problems. (since choco is modifying PowerShells Execution_Policies that works. )

I was wondering is there any way to fix this issue without choco (or not modifying PowerShells Execution_Policies) because per company policy I'm not allow to change PowerShells Execution_Policies

Windows 10,
VS Code
1.42.0 ,
Node 12.4

Thanks.

investigate

Most helpful comment

This is a working workaround:
Run this command as an administrator in PS-
Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope LocalMachine

the meaning and understanding this is all here:
https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-7

All 11 comments

Also related to https://github.com/microsoft/vscode-azurefunctions/issues/1678. It _seems_ like this is a v3 only problem, but not entirely sure.

That file, as well as func.cmd, are created by npm itself. I'm not sure how much control we can have over these files, but we could check if there is a way to sign them.

I was getting a related error message "Running scripts is disabled on this system" and sure enough the execution policy was set to restricted. It happened when, in VSCODE, I pressed F5 to kick off a build & serve.

It was working fine, then I switched my default terminal shell from gitbash to Powershell and it stopped working and gave that error. I switched back and it was fine again.

Flagging this as triaged so we can investigate whether there's anything we can do to sign that file.

This is a working workaround:
Run this command as an administrator in PS-
Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope LocalMachine

the meaning and understanding this is all here:
https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-7

FYI: This hit me as well after migrating from Core Tools v2 using Chocolatey to Core Tools v3 using NPM (as Chocolatey was lagging too much).

This just bit me too. Brand new install of VS Code, trying to get my first Azure Function working. I've seen it get some of my new dev's too. Let's get it fixed!

Anyone getting started with setting up an Azure Functions Core Tools environment has two gotchas

  1. Install via chocolatey - #693
  2. Install via npm - #1821

In our org, I've seen new devs get bit by both. It really slows us down during onboarding.

@fabiocav Can you please increase the priority of this? Until this is fixed Microsoft is basically asking users to disable their security to get Azure functions core tools to work :(

As Ahmed said earlier, this seems to be an issue in the npm cli itself -- https://github.com/npm/cli/issues/470.

One workaround suggested there is to delete func.ps1 file (in this case - C:\Program Files\nodejs\func.ps1), which will make func.cmd the default to run. Note: I haven't tried this yet.

Other tools, such as typescript CLI also encountered this issue -- https://github.com/microsoft/TypeScript/issues/35606

If this isn't fixed soon, maybe as a temporary fix, we could add code in our post install script to delete .ps1 that is created on install, if that's possible.

@ankitkumarr Thanks. Took the conversation upstream to the npm/cli team on issue 470.

Closing this one since we don't have any action item on use. This is caused by npm. Here is the related issue: https://github.com/npm/cli/issues/470.

Was this page helpful?
0 / 5 - 0 ratings