title | description | ms.topic | ms.date | ms.custom |
---|---|---|---|---|
Use JavaScript on Azure MariaDB |
To create or move your MariaDB database to Azure, you need a MariaDB resource. |
include |
08/08/2022 |
devx-track-js, devx-track-azurecli |
You can create a resource with:
- Azure CLI
- Azure portal
- @azure/arm-mariadb
[!INCLUDE Azure CLI commands]
While developing your MariaDB database with JavaScript, use one of the following tools:
- Azure Cloud Shell's mysql CLI
- MySQL Workbench
- Visual Studio Code extension
The Azure MariaDB uses npm packages already available, such as:
Note
This article contains references to the term slave, a term that Microsoft no longer uses. When the term is removed from the software, we’ll remove it from this article.
To connect and use your MariaDB on Azure with JavaScript, use the following procedure.
-
Make sure Node.js and npm are installed.
-
Create a Node.js project in a new folder:
mkdir mariaDbDemo && \ cd mariaDbDemo && \ npm init -y && \ npm install mariadb && \ touch index.js && \ code .
The command:
- creates a project folder named
mariaDbDemo
- changes the Bash terminal into that folder
- initializes the project, which creates the
package.json
file - installs the mariadb npm package
- creates the
index.js
script file - opens the project in Visual Studio Code
- creates a project folder named
-
Copy the following JavaScript code into
index.js
::::code language="JavaScript" source="~/../js-e2e/database/mariadb/index.js" :::
-
Replace the host, user, and password with your values in the script for your connection configuration object,
config
. -
Run the script.