Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V3 Functions project fails to launch with debugger because of PowerShell execution policy #1678

Open
kprpg opened this issue Nov 13, 2019 · 7 comments

Comments

@kprpg
Copy link

kprpg commented Nov 13, 2019

Repro steps:

  1. On a brand new Azure VM, which comes pre-installed with VS2019, VS Code etc.,. Create a durableFunction using v3, and launch debugger.
  2. You will see the below error on the Console output Window of VS Code.
    Executing task: func host start <

func : File C:\Users\gpillai\AppData\Roaming\npm\func.ps1 cannot be loaded. The file C:\Users\gpillai\AppData\Roaming\npm\func.ps1 is not digitally signed. You cannot run this script on the current system. For more
information about running scripts and setting execution policy, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:1

  • func host start
  •   + CategoryInfo          : SecurityError: (:) [], PSSecurityException
      + FullyQualifiedErrorId : UnauthorizedAccess
    

The terminal process terminated with exit code: 1

Action: azureFunctions.pickProcess
Error type: Error
Error Message: Failed to start debugging. Task "host start" failed with exit code "1".

Version: 0.20.0
OS: win32
Product: Visual Studio Code
Product Version: 1.40.0
Language: en

Call Stack
extension.bundle.js:353:75642extension.bundle.js:353:75642
l.fire extensionHostProcess.js:47:207
m.$onDidEndTaskProcess extensionHostProcess.js:695:468
@ejizba
Copy link
Member

ejizba commented Nov 13, 2019

@ankitkumarr @ahmelsayed @soninaren any ideas on this one? Is there some PowerShell script that isn't getting signed for v3?

@ejizba ejizba added the v3 label Nov 13, 2019
@ahmelsayed
Copy link
Member

hmm, I don't think there is anything special to v3 here. @kprpg does this work with npm installed v2?

@brettsam
Copy link
Member

brettsam commented Dec 9, 2019

@ahmelsayed -- we just had someone hit this during OGF run. Did we ever get to the bottom of this? What is func.ps1 -- is that something for VS Code?

@jthake
Copy link

jthake commented Dec 20, 2019

I have just hit this too. Brand new Windows 10 machine, with Visual Studio Code installed and only Azure Functions v3 installed. Following these steps https://docs.microsoft.com/en-us/azure/azure-functions/functions-run-local#create-func

using npm install -g azure-functions-core-tools@3

Visual Studio Code version info

Version: 1.41.1 (user setup)
Commit: 26076a4de974ead31f97692a0d32f90d735645c0
Date: 2019-12-18T14:58:56.166Z
Electron: 6.1.5
Chrome: 76.0.3809.146
Node.js: 12.4.0
V8: 7.6.303.31-electron.0
OS: Windows_NT x64 10.0.18363

If I then run npm install -g azure-functions-core-tools and in the project that I created when v3 was installed run func new it doesn't get that error anymore...

Actually, I was using the Terminal directly in Visual Studio Code and this error still shows. If I do this in the Windows 10 Terminal, I do not see this error.

Obviously this means that if I try debug and run in Visual Studio Code. This error prevents me from starting the host.

Running this in the Visual Studio Code terminal shows execution policies were not set up.

PS C:\> Get-ExecutionPolicy -List

        Scope ExecutionPolicy
        ----- ---------------
MachinePolicy       Undefined
   UserPolicy       Undefined
      Process       Undefined
  CurrentUser       Undefined
 LocalMachine       AllSigned

To get this to work. I had to run PowerShell as an Administrator and run
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned. More is documented here on this https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-6#managing-the-execution-policy-with-powershell .

@ejizba
Copy link
Member

ejizba commented Feb 12, 2020

Filed Azure/azure-functions-core-tools#1821 to track this on the core tools side

@ejizba ejizba changed the title V3 Functions in VS Code - DurableOrchestrator starter default project fails to launch with debugger V3 Functions project fails to launch with debugger because of PowerShell execution policy Feb 24, 2020
@hhubik
Copy link

hhubik commented Sep 6, 2021

I started running into this issue after installing the latest VS Code update:

Version: 1.60.0 (user setup)
Commit: e7d7e9a9348e6a8cc8c03f877d39cb72e5dfb1ff
Date: 2021-09-01T10:41:52.311Z
Electron: 13.1.8
Chrome: 91.0.4472.164
Node.js: 14.16.0
V8: 9.1.269.39-electron.0
OS: Windows_NT x64 10.0.19043

Fixed it by running the following in PowerShell NOT as an Administrator
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

@AzeemQ8
Copy link

AzeemQ8 commented Feb 21, 2023

I started running into this issue after installing the latest VS Code update:

Version: 1.60.0 (user setup)
Commit: e7d7e9a9348e6a8cc8c03f877d39cb72e5dfb1ff
Date: 2021-09-01T10:41:52.311Z
Electron: 13.1.8
Chrome: 91.0.4472.164
Node.js: 14.16.0
V8: 9.1.269.39-electron.0
OS: Windows_NT x64 10.0.19043

Fixed it by running the following in PowerShell NOT as an Administrator Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

Perfect Solution, Thank you Dear

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants