From 385d2ae75f1b263e703a6069d804129726b40ec5 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 21 May 2025 17:57:16 +0000 Subject: [PATCH 1/4] Initial plan for issue From 1a078a89e1066cc5057a80fd202843c70418aa03 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 21 May 2025 18:00:35 +0000 Subject: [PATCH 2/4] Add documentation for getDotEnvFilePath command Co-authored-by: spboyer <7681382+spboyer@users.noreply.github.com> --- ext/vscode/README.md | 3 ++ ext/vscode/docs/commands.md | 70 +++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 ext/vscode/docs/commands.md diff --git a/ext/vscode/README.md b/ext/vscode/README.md index 058669752fc..83940e505df 100644 --- a/ext/vscode/README.md +++ b/ext/vscode/README.md @@ -5,6 +5,9 @@ This extension makes it easier to run, create Azure Resources, and deploy Azure ## What It Does For more information about Azure Developer CLI and this VS Code extension, please [see the documentation](https://aka.ms/azure-dev/vscode). +## Extension Documentation +- [Available Commands](docs/commands.md) - Documentation for commands provided by this extension, including utility commands for use in VS Code configurations. + ## Tell Us What You Think! - [Give us a thumbs up or down](https://aka.ms/azure-dev/hats). We want to hear good news, but bad news are even more important! - Use [Discussions](https://aka.ms/azure-dev/discussions) to share new ideas or ask questions about Azure Developer CLI and the VS Code extension. diff --git a/ext/vscode/docs/commands.md b/ext/vscode/docs/commands.md new file mode 100644 index 00000000000..859a05248f1 --- /dev/null +++ b/ext/vscode/docs/commands.md @@ -0,0 +1,70 @@ +# VS Code Extension Commands + +This document describes the commands provided by the Azure Developer CLI Visual Studio Code extension. + +## Command List + +Most commands are available in the Command Palette (Ctrl+Shift+P or Cmd+Shift+P) and are prefixed with "Azure Developer CLI (azd)". + +## Utility Commands + +Some commands are not directly available in the command palette but are provided for use in other VS Code features. + +### azure-dev.commands.getDotEnvFilePath + +This command retrieves the path to the `.env` file for a specified Azure Developer environment or for the default environment if none is specified. This is useful for VS Code configurations where you need to access environment variables from an Azure Developer environment. + +#### Usage in launch.json + +One common use case is to configure a debug session to use environment variables from an Azure Developer environment's `.env` file. To do this, add the following to your `launch.json` file: + +```json +{ + "configurations": [ + { + // Your debug configuration + "envFile": "${input:azdDotenv}" + } + ], + "inputs": [ + { + "id": "azdDotenv", + "type": "command", + "command": "azure-dev.commands.getDotEnvFilePath" + } + ] +} +``` + +This configuration will use the `.env` file from the default Azure Developer environment. If you want to use a specific environment, you can pass its name as an argument: + +```json +{ + "inputs": [ + { + "id": "azdDotenv", + "type": "command", + "command": "azure-dev.commands.getDotEnvFilePath", + "args": ["my-environment-name"] + } + ] +} +``` + +#### Parameters + +The command accepts the following optional parameters as an array: + +1. `environmentName` (optional): The name of the environment to use. If not provided, the default environment will be used. +2. `workingDir` (optional): The working directory to use when looking for environments. If not provided, the first workspace folder will be used. + +#### Error Handling + +The command will throw an error if: + +- No working directory can be determined +- No Azure Developer environments are found +- The specified environment does not exist +- There is no default environment when none is specified + +These errors will be shown to the user when the debug session starts or when the command is executed. \ No newline at end of file From 304ff95d896b595397da0189cc4342a5a0315d16 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 21 May 2025 18:01:36 +0000 Subject: [PATCH 3/4] Add JSDoc comments to getDotEnvFilePath function Co-authored-by: spboyer <7681382+spboyer@users.noreply.github.com> --- ext/vscode/src/commands/getDotEnvFilePath.ts | 27 ++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/ext/vscode/src/commands/getDotEnvFilePath.ts b/ext/vscode/src/commands/getDotEnvFilePath.ts index e6ce9439fd1..8f21c6b0310 100644 --- a/ext/vscode/src/commands/getDotEnvFilePath.ts +++ b/ext/vscode/src/commands/getDotEnvFilePath.ts @@ -5,6 +5,33 @@ import { IActionContext } from "@microsoft/vscode-azext-utils"; import * as vscode from 'vscode'; import { getEnvironments, EnvironmentInfo } from "./cmdUtil"; +/** + * Get the path to the .env file for an Azure developer environment. + * + * This can be used in launch.json to provide environment variables to VS Code tasks: + * ```json + * { + * "configurations": [ + * { + * "envFile": "${input:azdDotenv}" + * } + * ], + * "inputs": [ + * { + * "id": "azdDotenv", + * "type": "command", + * "command": "azure-dev.commands.getDotEnvFilePath" + * } + * ] + * } + * ``` + * + * @param context - The VS Code extension action context + * @param args - Optional array containing [environmentName, workingDir] + * - environmentName: Name of the environment to use (uses default if not provided) + * - workingDir: Working directory to find environments (uses first workspace folder if not provided) + * @returns Path to the .env file for the specified environment + */ export async function getDotEnvFilePath(context: IActionContext, args: string[] | undefined): Promise { const [environmentName, workingDir] = args ?? []; From 6d20ad5de1d080b8adfb2f866935cc7cd70039dc Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 22 May 2025 20:48:28 +0000 Subject: [PATCH 4/4] Address PR feedback on VS Code extension commands documentation Co-authored-by: bwateratmsft <36966225+bwateratmsft@users.noreply.github.com> --- ext/vscode/README.md | 2 +- ext/vscode/docs/commands.md | 22 +++++++++------------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/ext/vscode/README.md b/ext/vscode/README.md index 83940e505df..9a3fcc9a0fb 100644 --- a/ext/vscode/README.md +++ b/ext/vscode/README.md @@ -6,7 +6,7 @@ This extension makes it easier to run, create Azure Resources, and deploy Azure For more information about Azure Developer CLI and this VS Code extension, please [see the documentation](https://aka.ms/azure-dev/vscode). ## Extension Documentation -- [Available Commands](docs/commands.md) - Documentation for commands provided by this extension, including utility commands for use in VS Code configurations. +- [Utility Commands](docs/commands.md) - Documentation for utility commands provided by this extension for use in VS Code configurations. ## Tell Us What You Think! - [Give us a thumbs up or down](https://aka.ms/azure-dev/hats). We want to hear good news, but bad news are even more important! diff --git a/ext/vscode/docs/commands.md b/ext/vscode/docs/commands.md index 859a05248f1..f63e72411a6 100644 --- a/ext/vscode/docs/commands.md +++ b/ext/vscode/docs/commands.md @@ -1,34 +1,30 @@ -# VS Code Extension Commands +# Azure Developer CLI VS Code Extension Commands -This document describes the commands provided by the Azure Developer CLI Visual Studio Code extension. - -## Command List - -Most commands are available in the Command Palette (Ctrl+Shift+P or Cmd+Shift+P) and are prefixed with "Azure Developer CLI (azd)". +This document describes utility commands provided by the Azure Developer CLI Visual Studio Code extension. ## Utility Commands -Some commands are not directly available in the command palette but are provided for use in other VS Code features. +The following utility commands are provided for use in VS Code configurations but are not directly available in the command palette. ### azure-dev.commands.getDotEnvFilePath -This command retrieves the path to the `.env` file for a specified Azure Developer environment or for the default environment if none is specified. This is useful for VS Code configurations where you need to access environment variables from an Azure Developer environment. +This command retrieves the path to the `.env` file for a specified Azure Developer CLI environment or for the default environment if none is specified. This is useful for VS Code configurations where you need to access environment variables from an Azure Developer CLI environment. #### Usage in launch.json -One common use case is to configure a debug session to use environment variables from an Azure Developer environment's `.env` file. To do this, add the following to your `launch.json` file: +One common use case is to configure a debug session to use environment variables from an Azure Developer CLI environment's `.env` file. To do this, add the following to your `launch.json` file: ```json { "configurations": [ { // Your debug configuration - "envFile": "${input:azdDotenv}" + "envFile": "${input:dotEnvFilePath}" } ], "inputs": [ { - "id": "azdDotenv", + "id": "dotEnvFilePath", "type": "command", "command": "azure-dev.commands.getDotEnvFilePath" } @@ -36,13 +32,13 @@ One common use case is to configure a debug session to use environment variables } ``` -This configuration will use the `.env` file from the default Azure Developer environment. If you want to use a specific environment, you can pass its name as an argument: +This configuration will use the `.env` file from the default Azure Developer CLI environment. If you want to use a specific environment, you can pass its name as an argument: ```json { "inputs": [ { - "id": "azdDotenv", + "id": "dotEnvFilePath", "type": "command", "command": "azure-dev.commands.getDotEnvFilePath", "args": ["my-environment-name"]