Skip to content

Commit acf868a

Browse files
committed
diberry/0519-tsp-js-2
1 parent d26e634 commit acf868a

File tree

2 files changed

+27
-21
lines changed

2 files changed

+27
-21
lines changed

articles/typespec/includes/quickstart/prereqs-typescript.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ms.date: 04/23/2025
66
* An active Azure account. [Create an account for free](https://azure.microsoft.com/free) if you don't have one.
77
* [Node.js LTS](https://nodejs.org/) installed on your system.
88
* [TypeScript](https://www.typescriptlang.org/) for writing and compiling TypeScript code.
9-
9+
* [Docker](https://www.docker.com/)
1010
* [Visual Studio Code](https://code.visualstudio.com/)
1111
* [TypeSpec extension](https://marketplace.visualstudio.com/items?itemName=typespec.typespec-vscode)
1212
* Optional: Deployment with [Azure Developer CLI](/azure/developer/azure-developer-cli/)

articles/typespec/quickstart-scaffold-typescript.md

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -86,20 +86,6 @@ TypeSpec defines your API in a language-agnostic way and generates the API serve
8686
TypeSpec **emitters** are libraries that utilize various TypeSpec compiler APIs to reflect on the TypeSpec compilation process and generate artifacts.
8787

8888
1. Wait for the initialization to complete before continuing.
89-
90-
```console
91-
Please review the following messages from emitters:
92-
@typespec/http-server-js:
93-
94-
Generated JavaScript services require a service runtime:
95-
https://nodejs.org/download
96-
97-
Create a JavaScript service project for your TypeSpec:
98-
> npx hsjs-scaffold
99-
100-
More information on getting started:
101-
https://aka.ms/tsp/hsjs/start
102-
```
10389
10490
1. Compile the project:
10591

@@ -194,7 +180,7 @@ Now that the basic Express.js API server is working, update the Express.js serve
194180
```
195181

196182
1. Create an `./tsp-output/server/src/azure` directory to hold source code specific to Azure.
197-
1. Create the `cosmos-client.ts` file in that directory to create a Cosmos DB client object and paste in the following code:
183+
1. Create the `cosmosClient.ts` file in that directory to create a Cosmos DB client object and paste in the following code:
198184

199185
```typescript
200186
import { CosmosClient, Database, Container } from "@azure/cosmos";
@@ -289,7 +275,7 @@ Now that the basic Express.js API server is working, update the Express.js serve
289275

290276
Notice the file uses the endpoint, database, and container. It doesn't need a connection string or key because it's using the Azure Identity credential `DefaultAzureCredential`. Learn more about this method of [secure authentication for both local and production](/azure/developer/javascript/sdk/authentication/overview) environments.
291277

292-
1. Create a new Widget controller, `./tsp-output/server/src/controllers/widgets-cosmos.ts`, and paste in the following integration code for Azure Cosmos DB.
278+
1. Create a new Widget controller, `./tsp-output/server/src/controllers/WidgetsCosmos.ts`, and paste in the following integration code for Azure Cosmos DB.
293279

294280
```typescript
295281
import { Widgets, Widget, WidgetList, AnalyzeResult,Error } from "../generated/models/all/demo-service.js";
@@ -501,12 +487,12 @@ Now that the basic Express.js API server is working, update the Express.js serve
501487
}
502488
```
503489

504-
1. Update the `./tsp-output/server/src/index.ts` to use the new controller.
490+
1. Update the `./tsp-output/server/src/index.ts` to import the new controller, get the Azure Cosmos DB environment settings, then create the WidgetsCosmosController and pass to the router`.
505491

506492
```typescript
507493
// Generated by Microsoft TypeSpec
508494
509-
import { WidgetsCosmosController } from "./controllers/widgets-cosmos.js";
495+
import { WidgetsCosmosController } from "./controllers/WidgetsCosmos.js";
510496
511497
import { createDemoServiceRouter } from "./generated/http/router.js";
512498
@@ -548,7 +534,7 @@ Now that the basic Express.js API server is working, update the Express.js serve
548534
});
549535
```
550536

551-
1. Compile the TypeScript into JavaScript.
537+
1. In a terminal at `./tsp-output/server`, compile the TypeScript into JavaScript.
552538

553539
```console
554540
tsc
@@ -902,7 +888,7 @@ Create the files needed to have a repeatable deployment with [Azure Developer CL
902888

903889
You can deploy this application to Azure using Azure Container Apps:
904890

905-
1. Authenticate to the Azure Developer CLI:
891+
1. In a terminal at the root of the project, authenticate to the Azure Developer CLI:
906892

907893
```console
908894
azd auth login
@@ -915,6 +901,26 @@ You can deploy this application to Azure using Azure Container Apps:
915901
azd up
916902
```
917903

904+
1. Answer the following prompts with the answers provided:
905+
906+
* Enter a unique environment name: `tsp-server-js`
907+
* Select an Azure Subscription to use: select your subscription
908+
* Select an Azure location to use: select a location near you
909+
* Pick a resource group to use: Select *Create a new resource group*
910+
* Enter a name for the new resource group: accept the default provided
911+
912+
1. Wait until the deployment completes. The response includes information similar to the following:
913+
914+
```console
915+
Deploying services (azd deploy)
916+
917+
(✓) Done: Deploying service api
918+
- Endpoint: https://container-app-123.ambitiouscliff-456.centralus.azurecontainerapps.io/
919+
920+
921+
SUCCESS: Your up workflow to provision and deploy to Azure completed in 6 minutes 32 seconds.
922+
```
923+
918924
## Use application in browser
919925

920926
Once deployed, you can:

0 commit comments

Comments
 (0)