Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"azureFunctions.suppressProject": true
"azureFunctions.suppressProject": true,
"dotnet.defaultSolution": "Azure.Functions.Cli.sln"
}
7 changes: 0 additions & 7 deletions Azure.Functions.Cli.sln
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{6EE1D011-2
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.Functions.Cli", "src\Cli\func\Azure.Functions.Cli.csproj", "{6608738C-3BDB-47F5-BC62-66A8BDF9D884}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.Functions.Cli.Tests", "test\Azure.Functions.Cli.Tests\Azure.Functions.Cli.Tests.csproj", "{EAEA6EDB-A301-4A50-86D8-91859DABE30E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ZippedExe", "test\ZippedExe\ZippedExe.csproj", "{2CD45039-0ABD-4082-87D0-52BB5D467B50}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Cli", "Cli", "{154FDAF2-0E86-450E-BE57-4E3D410B0FAC}"
Expand Down Expand Up @@ -41,10 +39,6 @@ Global
{6608738C-3BDB-47F5-BC62-66A8BDF9D884}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6608738C-3BDB-47F5-BC62-66A8BDF9D884}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6608738C-3BDB-47F5-BC62-66A8BDF9D884}.Release|Any CPU.Build.0 = Release|Any CPU
{EAEA6EDB-A301-4A50-86D8-91859DABE30E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EAEA6EDB-A301-4A50-86D8-91859DABE30E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EAEA6EDB-A301-4A50-86D8-91859DABE30E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EAEA6EDB-A301-4A50-86D8-91859DABE30E}.Release|Any CPU.Build.0 = Release|Any CPU
{2CD45039-0ABD-4082-87D0-52BB5D467B50}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2CD45039-0ABD-4082-87D0-52BB5D467B50}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2CD45039-0ABD-4082-87D0-52BB5D467B50}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down Expand Up @@ -83,7 +77,6 @@ Global
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{6608738C-3BDB-47F5-BC62-66A8BDF9D884} = {154FDAF2-0E86-450E-BE57-4E3D410B0FAC}
{EAEA6EDB-A301-4A50-86D8-91859DABE30E} = {6EE1D011-2334-44F2-9D41-608B969DAE6D}
{2CD45039-0ABD-4082-87D0-52BB5D467B50} = {6EE1D011-2334-44F2-9D41-608B969DAE6D}
{154FDAF2-0E86-450E-BE57-4E3D410B0FAC} = {5F51C958-39C0-4E0C-9165-71D0BCE647BC}
{78231B55-D243-46F1-9C7F-7831B40ED2D8} = {5F51C958-39C0-4E0C-9165-71D0BCE647BC}
Expand Down
143 changes: 100 additions & 43 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,75 +1,132 @@
## Running the latest runtime version
# Contributing to the Azure Functions CLI

## Dependencies
## Contributing to this Repository

There is a dependency on the .NET Core tools for the cross platform support. You can [install these here](https://www.microsoft.com/net/core).
### Filing Issues

To install the required dotnet packages navigate into the repository root and run `dotnet restore`
Filing issues is a great way to contribute to the SDK. Here are some guidelines:

## Compiling the CLI Tools
* Include as much detail as you can be about the problem
* Point to a test repository (e.g. hosted on GitHub) that can help reproduce the issue. This works better then trying to describe step by step how to create a repro scenario.
* Github supports markdown, so when filing bugs make sure you check the formatting before clicking submit.

To build the project run `dotnet build` from the root of the repository. This will build the project and all of its dependencies.
The output will be placed in the `out/bin/Azure.Functions.Cli/debug` directory.
### Submitting Pull Requests

`dotnet run --project src/Cli/func <command>` will run the CLI tool from the source directory.
If you don't know what a pull request is read this https://help.github.com/articles/using-pull-requests.

### Running against a function app
Before we can accept your pull-request you'll need to sign a [Contribution License Agreement (CLA)](http://en.wikipedia.org/wiki/Contributor_License_Agreement). You can sign ours [here](https://cla2.dotnetfoundation.org). However, you don't have to do this up-front. You can simply clone, fork, and submit your pull-request as usual.

To test this project against a local function app you can run from that function app's directory
When your pull-request is created, we classify it. If the change is trivial, i.e. you just fixed a typo, then the PR is labelled with `cla-not-required`. Otherwise it's classified as `cla-required`. In that case, the system will also also tell you how you can sign the CLA. Once you signed a CLA, the current and all future pull-requests will be labelled as `cla-signed`. Signing the CLA might sound scary but it's actually super simple and can be done in less than a minute.

- `cd myTestFunctionApp`
- `dotnet run --project PATH_TO_FUNCTIONS_CLI/src/Cli/func <command>`
Before submitting a feature or substantial code contribution please discuss it with the team and ensure it follows the product roadmap. Note that all code submissions will be rigorously reviewed and tested by the Azure Functions Core Tools team, and only those that meet the bar for both quality and design/roadmap appropriateness will be merged into the source.

where PATH_TO_FUNCTIONS_CLI is the absolute or relative path to the root of this repository.
## Running the CLI locally

Or you can add `out/bin/Azure.Functions.Cli/debug/func` to your `PATH` environment variable and run the command from anywhere.
### Dependencies

- `export PATH=$PATH:/path/to/Azure.Functions.Cli/out/bin/Azure.Functions.Cli/debug/func`
- `func <command>`
Install [.NET SDK](https://www.microsoft.com/net/core) for cross-platform support.

### Running the Test Suite
### Building the CLI

- Build the solution `dotnet build Azure.Functions.Cli.sln`
- As part of this build, the cli is copied into the test project's output directory (`out/bin/Azure.Functions.Cli.Tests/debug`) - this is what will be used by the tests
- If you wish to override this, you can set the `FUNC_PATH` environment variable to the path of the `func`/`func.exe` you wish to test against
- Run the test suite in Visual Studio Test Explorer or by running `dotnet test` from the `test` project root.
- i.e. `cd test/Azure.Functions.Cli.Tests; dotnet test`
Build the project from the repository root:

#### Storage Emulator
```bash
dotnet build
```

Some tests, namely E2E, require an Azure storage emulator to be running. You can download the storage emulator [here](https://learn.microsoft.com/azure/storage/common/storage-use-azurite?tabs=visual-studio%2Cblob-storage).
The output will be in `out/bin/Azure.Functions.Cli/debug/`.

Run the emulator before your run the tests.
### Running the CLI

> There is a script you can use for this as well, see `tools/start-emulators.ps1`
**Running and debugging:**

#### Templates Missing
- **VS Code** - Press `F5` to run and debug. You'll be prompted for:
1. The command (e.g., `start`, `new`, `init`)
2. Optional `--script-root` path to your test function app

If you see an error saying the templates folder is missing, you can download the templates using the `download-templates.ps1` script.
- **Visual Studio** - Press `F5` to run and debug. Configure the launch profile to set:
1. The command via `command line arguments`
2. Path to your test function app path via `working directory`

From the root of the repo, run:
**Command line:**

- `./eng/scripts/download-templates.ps1 -OutputPath "./out/bin/<test_project_name>/debug`
- e.g. "./out/bin/Azure.Functions.Cli.E2ETests/debug"
Run the CLI from source:

The script will download the template packages to a `templates` folder in the specified output directory.
```bash
dotnet run --project src/Cli/func -- <command>
```

## Contributing to this Repository
**Running against a specific function app:**

### Filing Issues
Option 1 - Run from the function app directory:

Filing issues is a great way to contribute to the SDK. Here are some guidelines:
```bash
cd myTestFunctionApp
dotnet run --project PATH_TO_CORE_TOOLS_REPO/src/Cli/func -- <command>
```

* Include as much detail as you can be about the problem
* Point to a test repository (e.g. hosted on GitHub) that can help reproduce the issue. This works better then trying to describe step by step how to create a repro scenario.
* Github supports markdown, so when filing bugs make sure you check the formatting before clicking submit.
Option 2 - Use the `--script-root` parameter:

### Submitting Pull Requests
```bash
dotnet run --project src/Cli/func -- <command> --script-root PATH_TO_TEST_APP
```

If you don't know what a pull request is read this https://help.github.com/articles/using-pull-requests.
Option 3 - Add the built executable to your PATH:

Before we can accept your pull-request you'll need to sign a [Contribution License Agreement (CLA)](http://en.wikipedia.org/wiki/Contributor_License_Agreement). You can sign ours [here](https://cla2.dotnetfoundation.org). However, you don't have to do this up-front. You can simply clone, fork, and submit your pull-request as usual.
```bash
export PATH=$PATH:/path/to/azure-functions-core-tools/out/bin/Azure.Functions.Cli/debug
func <command>
```

When your pull-request is created, we classify it. If the change is trivial, i.e. you just fixed a typo, then the PR is labelled with `cla-not-required`. Otherwise it's classified as `cla-required`. In that case, the system will also also tell you how you can sign the CLA. Once you signed a CLA, the current and all future pull-requests will be labelled as `cla-signed`. Signing the CLA might sound scary but it's actually super simple and can be done in less than a minute.
### Running Tests

Before submitting a feature or substantial code contribution please discuss it with the team and ensure it follows the product roadmap. Note that all code submissions will be rigorously reviewed and tested by the Azure Functions Core Tools team, and only those that meet the bar for both quality and design/roadmap appropriateness will be merged into the source.
Tests can be run using:

- **Visual Studio Test Explorer** - Use Test Explorer in Visual Studio
- **VS Code** - Using the `.NET Core Test Explorer` extension to discover and run tests
- **Command line** - Use `dotnet test` commands below

#### Unit Tests

```bash
dotnet test test/Cli/Func.UnitTests/Azure.Functions.Cli.UnitTests.csproj
```

#### E2E Tests

E2E tests require Azure Storage emulator (Azurite).

**Option 1 - Using the provided script:**

```bash
./eng/scripts/start-emulators.ps1
```

**Option 2 - Manual setup:**
- Download [Azurite](https://learn.microsoft.com/azure/storage/common/storage-use-azurite)
- Start Azurite before running tests:
```bash
azurite --silent --skipApiVersionCheck
```

Then run the E2E tests:

```bash
dotnet test test/Cli/Func.E2ETests/Azure.Functions.Cli.E2ETests.csproj
```

**Note:** The build automatically copies `func` to the test output directory (`out/bin/Azure.Functions.Cli.E2ETests/debug/`). To test a different `func` executable, set the `FUNC_PATH` environment variable:

```bash
export FUNC_PATH=/path/to/custom/func
```

#### Missing Templates

If tests fail due to missing templates, download them:

```bash
./eng/scripts/download-templates.ps1 -OutputPath "./out/bin/Azure.Functions.Cli.E2ETests/debug"
```

The script downloads templates to a `templates/` folder in the specified output directory.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,14 @@ func [--version] [--help] <command> [<args>] [--verbose]
| v3 | `brew tap azure/functions` <br> `brew install azure-functions-core-tools@3` |
| v2 | `brew tap azure/functions` <br> `brew install azure-functions-core-tools@2` |

If upgrading to a new version, you may have to run `brew update` to pull the latest formula
before you run the install command. Or, you can run `brew upgrade`.

> [!NOTE]
> Homebrew allows side-by-side installation of v2 and v3. You can switch versions with:
>
> `brew link --overwrite azure-functions-core-tools@3`


### Linux

Installation for Linux requires two steps:
Expand Down
7 changes: 7 additions & 0 deletions docs/debug-with-host.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,10 @@ export FUNC_CLI=<path-to-published-cli>
# Start the host inside the test app directory
$FUNC_CLI start
```

Windows:

```pwsh
$env:FUNC_CLI = "<path-to-published-cli>"
& $env:FUNC_CLI start
```
10 changes: 0 additions & 10 deletions test/Azure.Functions.Cli.Tests/.editorconfig

This file was deleted.

71 changes: 0 additions & 71 deletions test/Azure.Functions.Cli.Tests/ApplicationInsights.config

This file was deleted.

52 changes: 0 additions & 52 deletions test/Azure.Functions.Cli.Tests/Azure.Functions.Cli.Tests.csproj

This file was deleted.

Loading