forked from CloudA2Z-Code/azure-cli-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create new Mariadb scripts and remove extension for MySQL & PG (Azure…
…-Samples#230) * Add mariadb scripts * remove rdbms extension
- Loading branch information
1 parent
8b57f1b
commit 1092d1d
Showing
22 changed files
with
243 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/bash | ||
|
||
# Create a resource group | ||
az group create \ | ||
--name myresourcegroup \ | ||
--location westus | ||
|
||
# Create a MariaDB server in the resource group | ||
# Name of a server maps to DNS name and is thus required to be globally unique in Azure. | ||
# Substitute the <server_admin_password> with your own value. | ||
az mariadb server create \ | ||
--name mydemoserver \ | ||
--resource-group myresourcegroup \ | ||
--location westus \ | ||
--admin-user myadmin \ | ||
--admin-password <server_admin_password> \ | ||
--sku-name GP_Gen5_2 \ | ||
|
||
# Restore a server from backup to a new server | ||
az mariadb server restore \ | ||
--name mydemoserver-restored \ | ||
--resource-group myresourcegroup \ | ||
--restore-point-in-time "2018-02-11T13:10:00Z" \ | ||
--source-server mydemoserver |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/bin/bash | ||
az group delete --name myresourcegroup |
35 changes: 35 additions & 0 deletions
35
mariadb/change-server-configurations/change-server-configurations.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/bin/bash | ||
|
||
# Create a resource group | ||
az group create \ | ||
--name myresourcegroup \ | ||
--location westus | ||
|
||
# Create a MariaDB server in the resource group | ||
# Name of a server maps to DNS name and is thus required to be globally unique in Azure. | ||
# Substitute the <server_admin_password> with your own value. | ||
az mariadb server create \ | ||
--name mydemoserver \ | ||
--resource-group myresourcegroup \ | ||
--location westus \ | ||
--admin-user myadmin \ | ||
--admin-password <server_admin_password> \ | ||
--sku-name GP_Gen5_2 \ | ||
|
||
# Display all available configurations with valid values of an Azure Database for MariaDB server | ||
az mariadb server configuration list \ | ||
--resource-group myresourcegroup \ | ||
--server-name mydemoserver | ||
|
||
# Set value of *innodb_lock_wait_timeout* | ||
az mariadb server configuration set \ | ||
--resource-group myresourcegroup \ | ||
--server-name mydemoserver \ | ||
--name innodb_lock_wait_timeout \ | ||
--value 120 | ||
|
||
# Check the value of *innodb_lock_wait_timeout* | ||
az mariadb server configuration show \ | ||
--resource-group myresourcegroup \ | ||
--server-name mydemoserver \ | ||
--name innodb_lock_wait_timeout |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/bin/bash | ||
az group delete --name myresourcegroup |
26 changes: 26 additions & 0 deletions
26
mariadb/create-mariadb-server-and-firewall-rule/create-mariadb-server-and-firewall-rule.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/bash | ||
|
||
# Create a resource group | ||
az group create \ | ||
--name myresourcegroup \ | ||
--location westus | ||
|
||
# Create a MariaDB server in the resource group | ||
# Name of a server maps to DNS name and is thus required to be globally unique in Azure. | ||
# Substitute the <server_admin_password> with your own value. | ||
az mariadb server create \ | ||
--name mydemoserver \ | ||
--resource-group myresourcegroup \ | ||
--location westus \ | ||
--admin-user myadmin \ | ||
--admin-password <server_admin_password> \ | ||
--sku-name GP_Gen5_2 \ | ||
|
||
# Configure a firewall rule for the server | ||
# The ip address range that you want to allow to access your server | ||
az mariadb server firewall-rule create \ | ||
--resource-group myresourcegroup \ | ||
--server mydemoserver \ | ||
--name AllowIps \ | ||
--start-ip-address 0.0.0.0 \ | ||
--end-ip-address 255.255.255.255 |
2 changes: 2 additions & 0 deletions
2
mariadb/create-mariadb-server-and-firewall-rule/delete-mariadb.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/bin/bash | ||
az group delete --name myresourcegroup |
55 changes: 55 additions & 0 deletions
55
mariadb/create-mariadb-server-vnet/create-mariadb-server.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#!/bin/bash | ||
|
||
# To find the name of an Azure region in the CLI run this command: az account list-locations | ||
# Substitute <subscription id> with your identifier | ||
az account set --subscription <subscription id> | ||
|
||
# Create a resource group | ||
az group create \ | ||
--name myresourcegroup \ | ||
--location westus | ||
|
||
# Create a MariaDB server in the resource group | ||
# Name of a server maps to DNS name and is thus required to be globally unique in Azure. | ||
# Substitute the <server_admin_password> with your own value. | ||
az mariadb server create \ | ||
--name mydemoserver \ | ||
--resource-group myresourcegroup \ | ||
--location westus \ | ||
--admin-user mylogin \ | ||
--admin-password <server_admin_password> \ | ||
--sku-name GP_Gen5_2 | ||
|
||
# Get available service endpoints for Azure region output is JSON | ||
# Use the command below to get the list of services supported for endpoints, for an Azure region, say "westus". | ||
az network vnet list-endpoint-services \ | ||
-l westus | ||
|
||
# Add Azure SQL service endpoint to a subnet *mySubnet* while creating the virtual network *myVNet* output is JSON | ||
az network vnet create \ | ||
-g myresourcegroup \ | ||
-n myVNet \ | ||
--address-prefixes 10.0.0.0/16 \ | ||
-l westus | ||
|
||
# Creates the service endpoint | ||
az network vnet subnet create \ | ||
-g myresourcegroup \ | ||
-n mySubnet \ | ||
--vnet-name myVNet \ | ||
--address-prefix 10.0.1.0/24 \ | ||
--service-endpoints Microsoft.SQL | ||
|
||
# View service endpoints configured on a subnet | ||
az network vnet subnet show \ | ||
-g myresourcegroup \ | ||
-n mySubnet \ | ||
--vnet-name myVNet | ||
|
||
# Create a VNet rule on the sever to secure it to the subnet Note: resource group (-g) parameter is where the database exists. VNet resource group if different should be specified using subnet id (URI) instead of subnet, VNet pair. | ||
az mariadb server vnet-rule create \ | ||
-n myRule \ | ||
-g myresourcegroup \ | ||
-s mydemoserver \ | ||
--vnet-name myVNet \ | ||
--subnet mySubnet |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/bin/bash | ||
az group delete --name myresourcegroup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/bin/bash | ||
az group delete --name myresourcegroup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/bin/bash | ||
|
||
# Create a resource group | ||
az group create \ | ||
--name myresourcegroup \ | ||
--location westus | ||
|
||
# Create a MariaDB server in the resource group | ||
# Name of a server maps to DNS name and is thus required to be globally unique in Azure. | ||
# Substitute the <server_admin_password> with your own value. | ||
az mariadb server create \ | ||
--name mydemoserver \ | ||
--resource-group myresourcegroup \ | ||
--location westus \ | ||
--admin-user myadmin \ | ||
--admin-password <server_admin_password> \ | ||
--sku-name GP_Gen5_2 \ | ||
|
||
# Monitor usage metrics - CPU | ||
az monitor metrics list \ | ||
--resource "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myresourcegroup/providers/Microsoft.DBforMariaDB/servers/mydemoserver" \ | ||
--metric cpu_percent \ | ||
--interval PT1M | ||
|
||
# Monitor usage metrics - Storage | ||
az monitor metrics list \ | ||
--resource-id "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myresourcegroup/providers/Microsoft.DBforMariaDB/servers/mydemoserver" \ | ||
--metric storage_used \ | ||
--interval PT1M | ||
|
||
# Scale up the server to provision more vCores within the same Tier | ||
az mariadb server update \ | ||
--resource-group myresourcegroup \ | ||
--name mydemoserver \ | ||
--sku-name GP_Gen5_4 | ||
|
||
# Scale up the server to provision a storage size of 7GB | ||
az mariadb server update \ | ||
--resource-group myresourcegroup \ | ||
--name mydemoserver \ | ||
--storage-size 7168 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/bin/bash | ||
az group delete --name myresourcegroup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/bin/bash | ||
|
||
# Create a resource group | ||
az group create \ | ||
--name myresourcegroup \ | ||
--location westus | ||
|
||
# Create a MariaDB server in the resource group | ||
# Name of a server maps to DNS name and is thus required to be globally unique in Azure | ||
# Substitute the <server_admin_password> with your own value | ||
az mariadb server create \ | ||
--name mydemoserver \ | ||
--resource-group myresourcegroup \ | ||
--location westus \ | ||
--admin-user myadmin \ | ||
--admin-password <server_admin_password> \ | ||
--sku-name GP_Gen5_2 \ | ||
|
||
# List the configuration options for review | ||
az mariadb server configuration list \ | ||
--resource-group myresourcegroup \ | ||
--server mydemoserver | ||
|
||
# Turn on statement level log | ||
az mariadb server configuration set \ | ||
--name log_statement \ | ||
--resource-group myresourcegroup \ | ||
--server mydemoserver \ | ||
--value all | ||
|
||
# Set log_min_duration_statement time to 10 sec | ||
az mariadb server configuration set \ | ||
--name log_min_duration_statement \ | ||
--resource-group myresourcegroup \ | ||
--server mydemoserver \ | ||
--value 10000 | ||
|
||
# List the available log files and direct to a text file | ||
az mariadb server-logs list \ | ||
--resource-group myresourcegroup \ | ||
--server mydemoserver > log_files_list.txt | ||
|
||
# Download log file from Azure | ||
# Review log_files_list.txt to find the server log file name for the desired timeframe | ||
# Substitute the <log_file_name> with your server log file name | ||
# Creates the postgresql-<date>_000000.log file in the current command line path | ||
az mariadb server-logs download \ | ||
--name <log_file_name> \ | ||
--resource-group myresourcegroup \ | ||
--server mydemoserver |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 0 additions & 3 deletions
3
mysql/change-server-configurations/change-server-configurations.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 0 additions & 3 deletions
3
mysql/create-mysql-server-and-firewall-rule/create-mysql-server-and-firewall-rule.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 0 additions & 3 deletions
3
postgresql/change-server-configurations/change-server-configurations.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 0 additions & 3 deletions
3
.../create-postgresql-server-and-firewall-rule/create-postgresql-server-and-firewall-rule.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 0 additions & 3 deletions
3
postgresql/scale-postgresql-server/scale-postgresql-server.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters