Visual Studio 2022, Connected Services are not starting - azure

Using Visual Studio 2022 Version 17.4.0 Preview 4.0
I have defined two connected services in visual studio for my project, both of them in local containers. The first time I runned the project the containers were created and started, but after I purged them from docker (only the containers not the images) and tried to start them again, Visual Studio was not doing anything. I pressed like 100 times on start local dependencies with no result.
Visual Studio Project
No matter what I try, the containers are not starting in Docker. I restarted Docker, Visual Studio, removed the images from Docker (and pulled them again), removed Visual Studio Cache, rebuild the project, but nothing works. The Connected Services (containers) refuse to start.
The service dependencies:
{
"dependencies": {
"secrets": {
"type": "secrets.user"
},
"storage": {
"containerPorts": "10000:10000,10001:10001,10002:10002",
"secretStore": "LocalSecretsFile",
"containerName": "azurite",
"containerImage": "mcr.microsoft.com/azure-storage/azurite",
"type": "storage.container",
"connectionId": "AzureStorage"
},
"cosmosdb": {
"containerPorts": "8081:8081,10251:10251,10252:10252,10253:10253,10254:10254",
"secretStore": "LocalSecretsFile",
"containerName": "cosmosdb",
"containerImage": "mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator:mongodb",
"type": "cosmosdb.container",
"connectionId": "CosmosDB"
}
}
}

Related

Node.js live debugging in VSCode doesn't work

I have a small project (but issue also appears on the one created by npx create-react-app my-app). I use VsCode and developing inside container (https://code.visualstudio.com/docs/remote/containers) . Dockerfile is very minimal:
ARG VARIANT="16-bullseye"
FROM mcr.microsoft.com/vscode/devcontainers/javascript-node:0-${VARIANT}
devcontainer.json has, almost, just defaults:
{
"name": "Node.js",
"build": {
"dockerfile": "Dockerfile",
"args": { "VARIANT": "16-bullseye" }
},
"settings": {},
"extensions": [
"dbaeumer.vscode-eslint"
],
"remoteUser": "node"
}
To debug, I run npm start , then I (for the 1st time) i click on Debug URl.
On macOS everything works, including file monitoring, so when I change js file, npm is recompiling instantly.
On Windows 11 however, the last part doesn't work - I need to stop and start npm manually, to have changes implement.
I've even tried to remove .vscode directory from my profile - no change here...
Any idea what is going on? Why it does work on macOS and doesn't work on Windows ?
I have the same extensions on both systems...I just can't find what is going on with Windows machine...
EDIT: the issue seems to be related to "Remote Development" extension for vscode . Issue is present only when using this extension on Windows. So I've opened a bug there: https://github.com/microsoft/vscode-remote-release/issues/6633

AWS Toolkit + VSCode local testing

I'm trying to figure out how to use AWS toolkit for vscode. I go to the AWS extension and click Create New SAM Application, point to project directory and it creates a hello world function. Above it, it says Add Debug Configuration. I click that, choose nodejs 12.x and save the launch.json, but I don't get the run option. It still says Add Debug Configuration for some reason. How can I run my lambda functions locally in the console?
The launch.json file generates, but I can never run the code.
launch.json
{
"configurations": [
{
"type": "aws-sam",
"request": "direct-invoke",
"name": "new test:app.lambdaHandler (nodejs12.x)",
"invokeTarget": {
"target": "code",
"projectRoot": "new test/hello-world",
"lambdaHandler": "app.lambdaHandler"
},
"lambda": {
"runtime": "nodejs12.x",
"payload": {},
"environmentVariables": {}
}
}
]
}
I also tried navigating to the hello-world directory in terminal and executing node app.js, but it doesn't return anything
What am I doing wrong? I appreciate the help!
Make sure you have SAM CLI install in local, here are the instructions for installation https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html
Then run the command sam local start-api.
You should be able to access the api at http://127.0.0.1:3000/hello
You can also do the same via vscode by selecting Run > Run without debugging (shortcut: ctrl + F5)

How to enable mixed mode debugging in Visual Studio Code?

I have a C#.NET Core Web application that uses some C++ code for certain operations.
This web application is running on Cent OS 8. (I am a Windows Developer and working on Linux for first time and so with VSCode)
I only have the option to debug using VSCode in CentOS. I am familiar with VS2019 Mixed mode debugging but I am not able to find that option in VSCode. Does it not support it?
Launch.Json doesn't allow "profiles" to add to it, which was allowed in VisualStudio2019 which enabled the mixed mode debugging.
One work around I tried was making a Launch.json setting for gdb:
"configurations": [
{
"name": "(gdb) Attach",
"type": "cppdbg",
"request": "attach",
"program": "${workspaceFolder}/CSharpCodeBinary/ManagedCode.dll",
"processId": "${command:pickProcess}",
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
Once I run the ManagedCode.dll on a terminal, I attach to "dotnet" application hoping to get a breakpoint hit in the unmanaged cpp file (that generates UnmanagedCode.so).
The "ManagedCode.dll" is the C# NetCore assembly which loads the native "UnmanagedCode.so" for accessing unmanaged code.
I have built "UnmanagedCode.so" using g++ -Og switch to generate symbols.
Still I am getting no luck to hit the breakpoint.
I just want to somehow hit the breakpoint inside UnmanagedCode.so code. Any way is acceptable.

Visual Studio 2019 node.js docker remote debug: breakpoint set but not yet bound

I'm trying to attach remote debugger of Visual Studio 2019 to node.js app in docker container. What I do:
I have created example node.js/express project in Visual Studio using "Basic Node.js Express 4 Application" template.
I have created docker image with following dockerfile:
FROM node:alpine
ADD ./TestApp/ExpressTestApp/ /
ENTRYPOINT node --inspect="0.0.0.0" /app.js
I launch container with following command:
docker run -p 3000:3000 -p 9229:9229 test
The app works, pages open on address http://localhost:3000/, console output states that debugger is active:
Debugger listening on ws://0.0.0.0:9229/73b5b00d-a492-4842-81e5-d50c12e64ac9
For help, see: https://nodejs.org/en/docs/inspector
In Visual Studio 2019, I click "Debug -> Attach to process...". In opened dialog I choose "Chrome devtools protocol websocket (no authentication)", enter ws://localhost:9229/73b5b00d-a492-4842-81e5-d50c12e64ac9 as a connection target and I can see and connect to node.js debugger in docker:
I can successfully attach to the process (node.js output states "Debugger attached."). But I can't use breakpoints in source files. When I place brakepoint, it shows the message "The breakpoint will not currently be hit. Breakpoint set but not yet bound."
How to make it work in Visual Studio?
I've tried to debug my app in VS Code, using following launch.json:
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "attach",
"name": "Attach to remote",
"protocol": "inspector",
"port": 9229,
"localRoot": "${workspaceFolder}",
"remoteRoot": "/"
}
]
}
And it works perfectly. Breakpoints, variables values watching and etc. And I don't need to specify generated GUID of debugger, which is great too.
How to achieve the same thing in Visual Studio 2019?

How can I debug a Node.js application running with PM2 in VSCode?

Visual Studio code has some awesome debug functionality built in that makes it easy to debug applications with node. However, my application is configured to use PM2. How can I set up Visual Studio Code to debug with PM2?
You can add a launch configuration in VSCode, in the file named launch.json, that attaches to the process you want like this:
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "attach",
"name": "Attach to Process",
"processId": "${command:PickProcess}"
},
{...}
]
}
Press ctrl+shift+D to show the debug section in Visual Studio Code, pick "Attach to Process" and then press "play". VSCode will automatically show you the options available on you local machine. Besides the process ids of the running node processes VSCode shows the full path of your node app so it is easy to pick the right process to attach.

Resources