Skip to content

Commit c9a26de

Browse files
committed
docs: add deployment
1 parent 74f65dc commit c9a26de

1 file changed

Lines changed: 63 additions & 5 deletions

File tree

docs/workshop.md

Lines changed: 63 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -852,7 +852,7 @@ That wasn't much work, right?
852852
It's now time to test our API! First we need to start the server. Run the following command in the terminal:
853853
854854
```bash
855-
npm run start:server
855+
npm run dev:server
856856
``` -->
857857

858858
---
@@ -965,13 +965,71 @@ jobs:
965965
966966
Not bad! Copilot did a great job here, but we still need to change a few things to make it work.
967967
968-
In the last command in the bottom, we'll replace the web app name and the resource group. It's no secrets, so we can put in there directly.
968+
The last command is not enough to deploy our app, since we also need to create a Cosmos DB database and set the connection string.
969969
970-
- Replace `${{ secrets.AZURE_WEBAPP_NAME }}` with `"todo-copilot-${{github.actor}}"`. We're using `${{github.actor}}` to get your GitHub username, so we have a unique name for the web app.
970+
Remove the command entirely, and let's go step by step to ask Copilot what we need. Add this first comment:
971971
972-
- Replace `${{ secrets.AZURE_RESOURCE_GROUP }}` with `"rg-copilot-nodejs-todo"`.
972+
```bash
973+
# Create resource group rg-copilot-nodejs-todo
974+
```
975+
976+
Hit `enter`, and Copilot should suggest this command for you:
977+
978+
```bash
979+
az group create --name rg-copilot-nodejs-todo --location eastus
980+
```
981+
982+
Accept it, then now add this comment to create the database:
983+
984+
```bash
985+
# Create cosmosdb with default api
986+
```
987+
988+
Copilot should come up with something like this:
989+
990+
```bash
991+
az cosmosdb create --name copilot-nodejs-todo --resource-group rg-copilot-nodejs-todo
992+
```
993+
994+
Great! Accept it, and continue with this comment:
995+
996+
```bash
997+
# Deploy webapp using node 18
998+
```
999+
1000+
Now it you suggest a command similar than what it did in the first place:
1001+
1002+
```bash
1003+
az webapp up --sku F1 --name copilot-nodejs-todo --resource-group rg-copilot-nodejs-todo --runtime "node|18-lts"
1004+
```
1005+
1006+
Again, accept it, but we'll need to tweak the `--name` option a bit to make it unique, as it will also serve as the URL for your web app. Change it to something like `--name nodejs-todo-YOUR_GITHUB_USERNAME`.
1007+
1008+
And now we need to retrieve the connection string. Add this comment:
1009+
1010+
```bash
1011+
# Retrieve cosmosdb connection string
1012+
```
1013+
1014+
And start typing `DATABASE_CONNECTION_STRING=` so it know that we want to get the result inside this variable. Copilot should complete the line with:
1015+
1016+
```bash
1017+
DATABASE_CONNECTION_STRING=$(az cosmosdb keys list --name copilot-nodejs-todo --resource-group rg-copilot-nodejs-todo --type connection-strings --query "connectionStrings[0].connectionString" -o tsv)
1018+
```
1019+
1020+
Almost there! Finally, we need set the environment variable in the web app. Add this comment:
1021+
1022+
```bash
1023+
# Set connection string in webapp
1024+
```
1025+
1026+
And Copilot should suggest a command like this:
1027+
1028+
```bash
1029+
az webapp config appsettings set --name nodejs-todo-YOUR_GITHUB_USERNAME --resource-group rg-copilot-nodejs-todo --settings DATABASE_CONNECTION_STRING=$DATABASE_CONNECTION_STRING
1030+
```
9731031

974-
And with these changes, we're done.
1032+
All good! Now we should be set and ready to deploy.
9751033

9761034
### Deploying the application
9771035

0 commit comments

Comments
 (0)