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
21 changes: 21 additions & 0 deletions docs/www/docs/cli/swa-deploy.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,27 @@ If your project doesn't have any `staticwebapp.config.json` file, add one under
swa deploy ./my-dist --api-location ./api
```

#### Opt in to .NET 10 isolated

For a .NET 10 isolated Functions API, explicitly select the language and version:

```bash
swa deploy ./my-dist --api-location ./api --api-language dotnetisolated --api-version 10.0
```

The corresponding runtime setting in `staticwebapp.config.json` is:

```json
{
"platform": {
"apiRuntime": "dotnet-isolated:10.0"
}
}
```

The default .NET isolated version remains `8.0`. .NET 10 is not supported for the in-process `dotnet` runtime.
CLI runtime selection does not establish runtime availability in Azure Static Web Apps; verify support for your target environment before deploying.

### Deploy a Blazor app

To deploy a Blazor app with (optional) an API to Azure Static Web Apps, use the following steps:
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "2.0.10",
"version": "2.1.0",
"name": "@azure/static-web-apps-cli",
"description": "Azure Static Web Apps CLI",
"type": "module",
Expand Down
1 change: 1 addition & 0 deletions schema/staticwebapp.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,7 @@
"dotnet:8.0",
"dotnet-isolated:8.0",
"dotnet-isolated:9.0",
"dotnet-isolated:10.0",
"node:18",
"node:20",
"node:22",
Expand Down
17 changes: 17 additions & 0 deletions src/cli/commands/deploy/deploy.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,23 @@ describe("deploy", () => {
expect(SUPPORTED_VERSIONS.DotnetIsolated).toContain(env.FUNCTION_LANGUAGE_VERSION);
});

it.each(["8.0", "9.0", "10.0"])("should forward explicitly selected .NET isolated %s to the deployment process", async (apiVersion) => {
vi.spyOn(optionsModule, "isUserOrConfigOption").mockImplementation((option) => option === "apiLanguage" || option === "apiVersion");

await deploy({ outputLocation: "/test-output", dryRun: false, apiLanguage: "dotnetisolated", apiVersion });

expect(spawn).toHaveBeenCalledWith(
"mock-binary",
[],
expect.objectContaining({
env: expect.objectContaining({
FUNCTION_LANGUAGE: "dotnetisolated",
FUNCTION_LANGUAGE_VERSION: apiVersion,
}),
}),
);
});

it("should print an error when --env is an empty string", async () => {
await deploy({
outputLocation: "/test-output",
Expand Down
25 changes: 25 additions & 0 deletions src/core/constants.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { DEFAULT_CONFIG } from "../config.js";
import { DEFAULT_VERSION, SUPPORTED_VERSIONS } from "./constants.js";
import { getChoicesForApiLanguage, getDefaultVersion } from "./functions-versions.js";

describe("DEFAULT_CONFIG and DEFAULT_VERSION/SUPPORTED_VERSIONS consistency", () => {
it("DEFAULT_CONFIG.apiVersion should match DEFAULT_VERSION.Node", () => {
Expand All @@ -17,3 +18,27 @@ describe("DEFAULT_CONFIG and DEFAULT_VERSION/SUPPORTED_VERSIONS consistency", ()
expect(SUPPORTED_VERSIONS.Python).toContain(DEFAULT_VERSION.Python);
});
});

describe(".NET runtime selection", () => {
it("should offer .NET 10 isolated alongside the existing versions", () => {
const choices = getChoicesForApiLanguage("dotnetisolated");

expect(choices).toEqual([
{ title: "8.0", value: "8.0" },
{ title: "9.0", value: "9.0" },
{ title: "10.0", value: "10.0" },
]);
});

it.each(["dotnetisolated", "dotnet"])("should keep the %s default at .NET 8", (apiLanguage) => {
const version = getDefaultVersion(apiLanguage);

expect(version).toBe("8.0");
});

it("should not offer .NET 10 for the in-process runtime", () => {
const choices = getChoicesForApiLanguage("dotnet");

expect(choices).toEqual([{ title: "8.0", value: "8.0" }]);
});
});
2 changes: 1 addition & 1 deletion src/core/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ export const DEFAULT_VERSION = {
export const SUPPORTED_VERSIONS = {
Node: ["18", "20", "22"],
Dotnet: ["8.0"],
DotnetIsolated: ["8.0", "9.0"],
DotnetIsolated: ["8.0", "9.0", "10.0"],
Python: ["3.9", "3.10", "3.11"],
};

Expand Down
33 changes: 32 additions & 1 deletion src/core/utils/json.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { loadPackageJson } from "./json.js";
import { loadPackageJson, validateConfigFile } from "./json.js";
import { logger } from "./logger.js";

describe("json functions", () => {
describe("loadPackageJson()", () => {
Expand All @@ -9,4 +10,34 @@ describe("json functions", () => {
expect(pkg.type).toBe("module");
});
});

describe("validateConfigFile() API runtimes", () => {
it.each([
"dotnet-isolated:10.0",
"dotnet:8.0",
"dotnet-isolated:8.0",
"dotnet-isolated:9.0",
"node:18",
"node:20",
"node:22",
"python:3.9",
"python:3.10",
"python:3.11",
])("should accept %s", async (apiRuntime) => {
const config = { platform: { apiRuntime } };

const result = await validateConfigFile(config);

expect(result).toEqual(config);
});

it("should reject .NET 10 for the in-process runtime", async () => {
vi.spyOn(logger, "error").mockImplementation(() => {});
const config = { platform: { apiRuntime: "dotnet:10.0" } };

const result = await validateConfigFile(config);

expect(result).toBeNull();
});
});
});
Loading