Debugging Azure Function with vscode - visual-studio-code

I've been struggling to debug an HttpTrigger type azure function with vscode.
My assumption is that the issue might be related to the config files within .vscode/ or at worst, my own environment.
As of now, when I try to debug a recently created function (func init) I get the following error from vscode:
> Executing task: dotnet clean /property:GenerateFullPaths=true /consoleloggerparameters:NoSummary <
execvp(3) failed.: Permission denied
The terminal process "dotnet 'clean', '/property:GenerateFullPaths=true', '/consoleloggerparameters:NoSummary'" failed to launch (exit code: 1)
Inside .vscode/ there 4 files:
├── extensions.json
├── launch.json
├── settings.json
└── tasks.json
and inside task.json there are a few dotnet related commands that are causing the error above.
Despite these files being automatically generated by core tools (func) I removed the dotnet lines from task.json and hit Debug.
After a few seconds I get:
Failed to detect running Functions host within "60" seconds. You may want to adjust the "azureFunctions.pickProcessTimeout" setting.
Is there any command to automatically generate the debug configuration? e.g. ".NET generate assets for build and debug"
Have you faced anything similar to it?
My env settings:
OS: Ubuntu 20.04.4 LTS
Code:1.64.2 x64
Azure Functions Extension: v1.6.0
Core Tools Version: 3.0.3904

Replacing the type from process to shell inside tasks.json solved it.
FWIW, https://github.com/OmniSharp/omnisharp-vscode/issues/4556

Related

Cargo build broke after using VS code

For a while I have been editing my Rust program with Pycharm Professional. However, I was curious and experimented with VS Code. At first my project was compiling and running. However, it suddenly started throwing a pretty wild error on cargo build and cargo run (while cargo check is fine), even in cmd outside of VS Code:
error: linking with `link.exe` failed: exit code: 1104
= note: "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.30.30705\\bin\\HostX64\\x64\\link.exe" "/NOLOGO" "C:\\rust\\book\\target\\debug\\deps\\book.1apvyby1qhuehv3.rcgu.o" "C:\\rust\\book\\target\\debug\\deps\\book.1cw7xmk0cjjg5uln.rcgu.o" "C:\\rust\\book\\target\\debug\\deps\\book.1e8ho0j4rykowhcr.rcgu.o" "C:\\rust\\book\\target\\debug\\deps\\book.1g2fbveo2gp7bxds.rcgu.o"
..............
..............
= note: LINK : fatal error LNK1104: cannot open file 'C:\rust\book\target\debug\deps\book.exe'
book is the name of my project.
I am on Windows 10, System Type: x64-based PC.
VS Code version 1.63.2
Sometimes VSCode file watcher watches the files in target/, that is not good.
So open the Settings, search for exclude, and in all "list-like" cofigurations add **/target/**, do a cargo clean and restart VSCode. This should fix this and future problems
Had to remove the directory, and redownload the whole project(used Git).

VSTFS build failed at Publish step

I am using the VSTFS CI/CD pipeline to automate my .NET Core 5.0 with Angular 12 web application.
It failing the build at Publish step (see below screenshot) with error:
'npm' is not recognized as an internal or external command,
2021-12-13T20:19:46.9855025Z operable program or batch file.
2021-12-13T20:19:46.9917349Z D:\TFSBuildAgent\_work\58\s\src\WebUI\WebUI.csproj(85,5): error MSB3073: The command "npm install" exited with code 9009.
2021-12-13T20:19:47.0482106Z ##[error]Error: C:\Program Files\dotnet\dotnet.exe failed with return code: 1
2021-12-13T20:19:47.0496257Z ##[error]Dotnet command failed with non-zero exit code on the following projects :
What could be the issue?
Thanks
It looks like npm is not found by the agent. Make sure Node is installed globally on the machine and npm has been added to the system wide path environment variable.
Or add the Node Tool Installer task to your workflows.
I fixed the issue by deleting the npm publish tag in WebUI project file.

Getting ModuleNotFoundError in python, package exists in virtual environment though

I am new to python and writing my first python file using Visual Studio Code. Till yesterday the code was working fine. But today it is starting to give ModuleNotFoundError. I double-checked the package and the package is there under lib folder of the virtual environment. Moreover, IntelliSense is also working fine, whenever I write import it shows the requests module in the available list. I am facing problems with IntelliSense also, as sometimes it stops working for no reason.
The major change that I did before executing the code is the integration of GitLab with my project.
Python Version: 3.6.2
Operating System: Windows
Git Version: 2.23.0
Pylint Version: 2.3.1
pip Version: 19.2.2
Requests Version: 2.22.0
Pytest Version: 5.1.1
Enabled Extensions:
Npm
Npm Intellisense
Ayu
Code Runner
AYU
Markdownlint
Predawn Themekit
Python by Microsoft
Can anyone have gone through with the same problem? Please help me to resolve this issue.
Attachments
Issue resolved I was running it using Ctrl+Alt+N (code-runner shortcut to run a project)which was creating this issue. But running the file in terminal using Run Python File in Terminal (option in the context menu when we do right-click in source .py file) giving me the expected result without any error.
Then I googled for how to alter this behavior so that I can get the same results by using Ctrl+Alt+N as well.
I found that; I need to add the following script under user's settings.json.
"code-runner.executorMap": {
"python": "h:\\practice\\virtualenv\\Scripts\\activate.bat && python -u"
}
Here is my complete user's settings.json
{
"workbench.colorTheme": "Predawn",
"workbench.iconTheme": "ayu",
"window.zoomLevel": 0,
"code-runner.executorMap": {
"python": "h:\\practice\\virtualenv\\Scripts\\activate.bat && python -u"
}
}

How to avoid Edeliver deployment error: "vm.args: No such file or directory"?

Context
We are trying to use edeliver to deploy a "Hot Upgrade" of a Phoenix Web Application to a remote Virtual Machine instance.
Our aim is to build an "upgrade" version of the app each time so that the app can be "hot" upgraded in production without any down-time.
We have succeeded in doing this "hot upgrade" on a "Hello World" phoenix app:
https://github.com/nelsonic/hello_world_edeliver which is automatically deployed from Travis-CI when the build passes. see: https://travis-ci.org/nelsonic/hello_world_edeliver/builds/259965752#L1752
So, in theory this technique should work for our "real" app.
Attempting to Deploy a "Real" Phoenix App using Edeliver
Ran the following command (to build the upgrade):
mix edeliver build upgrade --auto-version=git-revision --from=$(git rev-parse HEAD~) --to=$(git rev-parse HEAD) --verbose
i.e. "build the upgrade from the previous git revision to the current one"
So far, so good. "Release successfully built!"
Error: vm.args: No such file or directory
When we attempt to deploy the upgrade:
mix edeliver deploy upgrade to production --version=1.0.3+86d55eb --verbose
cat: /home/hladmin/healthlocker/releases/1.0.3+86d55eb/vm.args: No such file or directory
Note: we have a little bash script that reads the latest upgrade version available in .deliver/releases and deploys that see: version.sh
Question:
Is there a way to ignore the absence of the vm.args file and continue the deployment?
Or if the file is required to complete the deployment, is there some documentation on how to create the file?
Note: we have read the distillery "Runtime Configuration" docs: https://github.com/bitwalker/distillery/blob/master/docs/Runtime%20Configuration.md and are sadly none-the-wiser ...
Additional Info
Environment
Localhost: Mac running Elixir 1.4.2
Build Host: Ubuntu 16.04.2 LTS running Elixir 1.4.5
mix.exs file: https://github.com/healthlocker/healthlocker/blob/continuous-delivery/mix.exs
edeliver version: 1.4.4
Build tool: distillery version: 1.4.0
Umbrella project: yes.
This question was also asked on: https://github.com/edeliver/edeliver/issues/234
As mentioned by others, the vm.args file is necessary for BEAM to run the release. A default file is created by distillery during the release build process and should be located in releases/<version>/vm.args. From your log output it looks like expected directory is being checked.
Can you show us the contents of /home/hladmin/healthlocker/releases/?
Can you confirm that the default vm.args file is being created when building the release and extracting it (outside of the upgrade process)?
You also asked:
Or if the file is required to complete the deployment, is there some documentation on how to create the file?
If diagnosing the problem with the default vm.args file doesn't get you anywhere, you can also write your own file and configure distillery to use that file instead of the default. The details for this are in the distillery configuration docs. In short,
add the vm_args setting to your distillery config, which should be at rel/config.exs(relative to your project root), for example:
environment :prod do
set vm_args: "<path>/vm.args"
[...]
end

Build agent fails on second run for ASP.net 5 on VSO

I'm using VSO to create an automated build for a newly created ASP.NET 5 project. I followed the MSDN post and with a couple of tweaks, the following items work:
Automated build and deploy of ASP.NET project in VSO
Build and deploy of ASP.NET project from my laptop using VS 2015
What I'm trying to do is create a build agent on my laptop. I downloaded the agent.zip file and ran the powershell configuration script. When I queue the first build, VSO contacts my build agent and the build works and is published to Azure.
What does not work is the second time I queue a build. The build fails executing the following command:
Get-ChildItem -Path $PSScriptRoot\src -Filter project.json -Recurse | ForEach-Object { & echo $_.FullName }
The error is:
2016-02-09T17:13:50.1055064Z C:\agent\_work\1\s\MyMeds\src\MyMeds\project.json
2016-02-09T17:13:50.4535551Z ##[error]Get-ChildItem : The specified path, file name, or both are too long. The fully qualified file name must be less than
2016-02-09T17:13:50.4535551Z ##[error]260 characters, and the directory name must be less than 248 characters.
2016-02-09T17:13:50.4535551Z ##[error]At C:\agent_work\1\s\MyMeds\Prebuild.ps1:28 char:1
I would have guessed the work area would have been cleared out before the build started, but it does not seem to be the case. Also, if I manually clear the _work directory, the build succeeds. I've tried to clear the work are from within the PowerShell script, but this fails because the script is running in that directory.
Any suggestions of how to clear the work directory so that multiple builds will succeed ?
This is caused by the npm install command in the "PrePublish" script and the npm version used by VS.
"scripts": {
"prepublish": [ "npm install npm#latest", "npm version", "npm install", "bower install", "gulp clean", "gulp min" ]
}
Windows MAXPATH is limited to 260 characters while the old npm version does not apply this. The latest npm 3.x version has fixed this issue. But VS always use 1.4.9 version which cause the long path issue. See this issue for details: Update node to 5.x and npm to 3.x
The workaround for now would be remove the prepublish script from your project.json file and add additional steps in your build definition to perform these actions.