Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/paladique/azuresample-guestbook
Guestbook using MySQL and Cosmos DB on Azure
https://github.com/paladique/azuresample-guestbook
cosmosdb data mysql spa websockets
Last synced: 18 days ago
JSON representation
Guestbook using MySQL and Cosmos DB on Azure
- Host: GitHub
- URL: https://github.com/paladique/azuresample-guestbook
- Owner: paladique
- License: mit
- Created: 2020-10-13T22:20:54.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2020-11-17T23:27:00.000Z (almost 4 years ago)
- Last Synced: 2024-10-18T15:21:06.959Z (27 days ago)
- Topics: cosmosdb, data, mysql, spa, websockets
- Language: JavaScript
- Homepage:
- Size: 26.4 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Data Driven Guestbook
[Guestbooks](https://en.wikipedia.org/wiki/Guestbook) are a way for visitors to a event or location to leave their mark, typically with their name and message. Around the late 1990s/early 2000s, digital guestbooks were pretty popular.
This simplified demo is a digital guestbook that walks through different types of data, using the Azure Data platform.
👷🏿♀️⚠ *This is functional, but still a work in progress! Contributions welcome!*
## How it works
[See it in action!](https://sdcdatademo.azurewebsites.net/)
This demo is single page application (SPA), written in JavaScript that reads from MySQL and Cosmos DB databases.
Features:
- Grabs all entries from both databases, displays which database it came from, and sorts them by date
- Adds new entries to database of choice and updates page
- Notifies all users of new entries using Web Sockets## Azure Resources Uses
- [Azure DB for MySQL](https://docs.microsoft.com/azure/mysql/overview?WT.mc_id=academic-0000-jasmineg)
- [Cosmos DB (Mongo DB API)](https://docs.microsoft.com/azure/cosmos-db/mongodb-introduction?WT.mc_id=academic-0000-jasmineg)
- [Azure App Service (optional)](https://docs.microsoft.com/azure/app-service/?WT.mc_id=academic-0000-jasmineg)## How to Run
### Requirements
- [Azure Account](https://azure.microsoft.com/free/?WT.mc_id=academic-0000-jasmineg)
- [Node.js](https://nodejs.org/)
- Clone/download this repo## Create and configure Azure resources
*Recommended: Once your Azure resources are deployed, pin it to your dashboard in the Azure Portal*
1. Click this button to create a MySQL and CosmosDB Database in Azure, wait a few minutes for your services to be created. **Keep note of the resource group you created so you can find your databases later!**
[![Deploy to Azure](https://aka.ms/deploytoazurebutton)](https://portal.azure.com/?WT.mc_id=academic-0000-jasmineg#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2Fpaladique%2FSample-IntroData%2Fmain%2Ftemplate%2FdeployTemplate.json)
2. After your services has been created, go to the [Azure portal](portal.azure.com)## Configure MySQL
3. Open your MySQL Server (starts with `mysql-`).
4. Download this [certificate](https://www.digicert.com/CACerts/BaltimoreCyberTrustRoot.crt.pem) and copy to the root of this directory. [***Why you have to do this***](https://docs.microsoft.com/azure/mysql/howto-configure-ssl?WT.mc_id=academic-0000-jasmineg)
5. On the left menu, visit **Connection Security** and click **+ Add client IP*** to add a firewall rule for your ip address.
6. Set **Allow access to Azure Services** to **On**.
7. Go back to the **Overview** in MySQL. Your **server name** and **server admin login name**
8. Click on the terminal icon at the top of the portal to open the Cloud Shell Terminal.
9. Connect to MySQL with the following command replace the `servername` and `server admin login name` with the values in the overview of MySQL:`mysql -h servername.mysql.database.azure.com -u adminname@servername -p`
You're now connected to your MySQL server. The following commands will set up the database and table:
`USE guestdb;`
```sql
CREATE TABLE guestbook
(
id serial PRIMARY KEY,
entrydate datetime default now(),
sender VARCHAR(100),
message VARCHAR(200)
);
```In the .env file, enter the following values:
```javascript
SQLHost = [servername from overview]
SQLUser = [server admin login name from overview]
SQLPassword = [password for admin login]
```## Visit Cosmos DB
10. Open your Cosmos DB database (starts with `cosmos-`).
11. On the left menu, visit **Connection String** and copy the **Primary conenction string**In the .env file, enter the following values:
`CosmosConn= [connection string]`
## Run the code
Navigate to the code in your favorite command line tool (You will already be there if using VS Code's terminal)
it should look something like
`some\path\directory\Sample-IntroData`Enter the following commands:
`npm install`
`npm start`Visit [localhost:3000](http://localhost:3000/)
### Deploy this site to Azure
Checkout this documentation on how to [deploy this to Azure](https://docs.microsoft.com/azure/app-service/quickstart-nodejs?WT.mc_id=academic-0000-jasmineg&pivots=platform-linux#deploy-to-azure)!
## After you're done
If you're all done running this sample, [delete the resource group](https://docs.microsoft.com/azure/azure-resource-manager/management/delete-resource-group?WT.mc_id=academic-0000-jasmineg&tabs=azure-portal) that you selected or created when you created the databases.
## Learn more
- [Azure SQL Fundamentals](aka.ms/sdc/SqlFun)
- [Azure Data Fundamentals](https://docs.microsoft.com/learn/paths/azure-data-fundamentals-explore-core-data-concepts/?WT.mc_id=academic-0000-jasmineg)Contributions are welcome!