Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add azd deployment option #26

Merged
merged 2 commits into from
Feb 5, 2024
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
*.user
*.userosscache
*.sln.docstates
*.env
*.azure

# npm modules
**/node_modules/*

# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
Expand Down
49 changes: 32 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,46 @@
# WebApp with Cosmos DB

A sample webapp deployed on app service with cosmos db as database. It counts the number of visitors visiting the page and inserts the same into a sample collection in Cosmos DB.

### Installation
A sample web app deployed on Azure App Service with a Cosmos DB database. The app counts the number of visitors visiting the page and inserts the same number of entries into a sample collection in Cosmos DB.

1. In your terminal window, log into Azure and set a subscription(subscription which would contain the webapp) :
This sample application is used in the [Azure Load Testing tutorial about identifying performance bottlenecks](https://learn.microsoft.com/azure/load-testing/tutorial-identify-bottlenecks-azure-portal).

az login
az account set -s mySubscriptionName
## Deployment

2. Clone the sample application's source repository. The sample application is a Node.js app consisting of an Azure App Service web component and a Cosmos DB database. The repo also contains a PowerShell script that deploys the sample app to your Azure subscription.
To deploy the sample application to Azure, you'll use the Azure Developer CLI (azd). Check out the [Azure Dev CLI documentation for more instructions on using the CLI](https://learn.microsoft.com/en-us/azure/developer/azure-developer-cli/get-started).

git clone https://github.com/Azure-Samples/nodejs-appsvc-cosmosdb-bottleneck.git
1. Run the following command to initialize the project.

3. Deploy the sample app using the PowerShell script. (Tip: macOS users can install PowerShell [here](https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell-core-on-macos?view=powershell-7.1))
```bash
azd init --template https://github.com/Azure-Samples/nodejs-appsvc-cosmosdb-bottleneck/tree/azd
```

cd SampleApp
.\deploymentscript.ps1
This command will clone the code to your current folder and prompt you for the following information:

4. You will be prompted to supply a unique application name and a location (default is `eastus`). A resource group for the resources would be created with the same name.
5. Once deployment is complete, browse to the running sample application with your browser.
- `Environment Name`: This will be used as a prefix for the resource group that will be created to hold all Azure resources. This name should be unique within your Azure subscription.

https://<app_name>.azurewebsites.net
## **Clean up resources**
1. Run the following command to build a deployable copy of your application, provision the template's infrastructure to Azure and also deploy the application code to those newly provisioned resources.

```bash
azd up
```

This command will prompt you for the following information:

- `Azure Subscription`: The Azure Subscription where your resources will be deployed.
- `Azure Location`: The Azure location where your resources will be deployed.

> NOTE: This may take a while to complete as it executes three commands: `azd package` (builds a deployable copy of your application), `azd provision` (provisions Azure resources), and `azd deploy` (deploys application code). You will see a progress indicator as it packages, provisions and deploys your application.

1. Once deployment is complete, you can browse to the running sample application.

https://<app_name>.azurewebsites.net

## Clean up resources

You may want to delete the resources to avoid to continue incurring charges. Use the `az group delete` command to remove the resource group and all related resources.

az group delete --name myResourceGroup
```bash
azd down
```

Similarly, you can utilize the **Delete resource group** toolbar button on the sample application's resource group to remove all the resources.
Alternately, you can use the **Delete resource group** toolbar button in the Azure portal on the sample application's resource group to remove all the resources.
10 changes: 10 additions & 0 deletions azure.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/Azure/azure-dev/main/schemas/v1.0/azure.yaml.json

name: nodejs-appsvc-cosmosdb-bottleneck
metadata:
template: [email protected]
services:
web:
project: ./src
language: js
host: appservice
144 changes: 0 additions & 144 deletions css/site.css

This file was deleted.

101 changes: 0 additions & 101 deletions deploymentscript.ps1

This file was deleted.

Binary file removed fonts/segoeuil.ttf
Binary file not shown.
11 changes: 0 additions & 11 deletions img/azureCosmosDB.svg

This file was deleted.

1 change: 0 additions & 1 deletion img/cloneWhite.svg

This file was deleted.

1 change: 0 additions & 1 deletion img/deployWhite.svg

This file was deleted.

1 change: 0 additions & 1 deletion img/lightbulbWhite.svg

This file was deleted.

1 change: 0 additions & 1 deletion img/stackWhite.svg

This file was deleted.

1 change: 0 additions & 1 deletion img/successCloudNew.svg

This file was deleted.

Loading