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

Major additions - including deployment scripts and sql examples #2

Merged
merged 3 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,21 @@ Oracle Database@Azure brings Oracle's best databases - Exadata and Autonomous Da
* Quickly react to business demands using one converged, fully automated database that’s optimized for all workloads and data formats.

## Getting Started
* [Install the Azure CLI](https://learn.microsoft.com/en-us/cli/azure/)
* [Deploy a new Oracle Autonomous Database using the Azure CLI](azure-cli/deploy-adb.md)
* Get started with Select AI ([enable access](sql/select-ai-admin-enable.sql) | [samples](sql/select-ai-get-started.sql))
* [Subscribe to Oracle Database@Azure](https://www.youtube.com/watch?v=MEB8kB_TI2I)
* Deploy a new Oracle Autonomous Database
* [Using the Azure Portal](https://youtu.be/QOCvRr5CfeQ)
* [Using Terraform scripts](https://github.com/oci-landing-zones/terraform-oci-multicloud-azure/tree/main)
* [Using the Azure CLI](azure-cli/create-adb.md)
* Connect to your Autonomous Database
* [Learn about connectivity options](https://docs.oracle.com/en/cloud/paas/autonomous-database/serverless/adbsb/connect-preparing.html)
* Use these great VS Code extensions that help you develop and debug your database apps
* SQL Developer for VS Code ([Learn More](https://www.oracle.com/database/sqldeveloper/vscode/) | [Marketplace](https://marketplace.visualstudio.com/items?itemName=Oracle.sql-developer))
* Oracle Developer Tools for VS Code ([Learn More](https://docs.oracle.com/en/database/oracle/developer-tools-for-vscode/getting-started/gettingstarted.html) | [Marketplace](https://marketplace.visualstudio.com/items?itemName=Oracle.oracledevtools))
* [Sample SQL code](./sql/sql-scripts.md)
* Create a database user and add sample data
* Work with data in Azure Storage
* Get started with Select AI
* .... and more

<!--

Expand Down
38 changes: 34 additions & 4 deletions azure-cli/config
Original file line number Diff line number Diff line change
@@ -1,6 +1,36 @@
# Copyright (c) 2024 Oracle and/or its affiliates.
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/

# update the values below to match your requirements
LOCATION="eastus"
RESOURCE_GROUP="resource-group-name-goes-here"
VNET_ID="vnet-resource-name-goes-here"
SUBNET_ID="subnet-resource-name-goes-here"
ADB_NAME="adb-name-goes-here"
RESOURCE_GROUP="development"
ADB_NAME="quickstart"

## NETWORKING
# database
VNET_NAME="dev-vnet"
VNET_PREFIX="192.168.0.0/16"
# subnet for the database
SUBNET_NAME="dev-sn-db"
SUBNET_PREFIX="192.168.1.0/24"
# client subnet
SUBNET2_NAME="dev-sn-client"
SUBNET2_PREFIX="192.168.2.0/24"

#network security group
NSG_NAME=$SUBNET2_NAME-nsg

## COMPUTE VM
VM_NAME="adb-vm-client"
VM_PREFERRED_SIZES=( "Standard_DS3_v2" "Standard_DC1s_v2" "Standard_DC2s_v2" "Standard_DC2ads_v5" "Standard_L4s" )
VM_IMAGE="MicrosoftWindowsDesktop:Windows-11:win11-22h2-pro:latest"

## CLOUD STORAGE
# Storage accounts require a unique name across azure. Enter your unique name below.
STORAGE_ACCOUNT_NAME="your-storage-account"
STORAGE_CONTAINER_NAME="adb-sample"

## IDENTITIES
# This identity will be used for your VM. The password will also be used for the database ADMIN user
USER_NAME="adb"
USER_PASSWORD="your-complex-password"
36 changes: 36 additions & 0 deletions azure-cli/config.default
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Copyright (c) 2024 Oracle and/or its affiliates.
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/

# update the values below to match your requirements
LOCATION="eastus"
RESOURCE_GROUP="development"
ADB_NAME="quickstart"

## NETWORKING
# database
VNET_NAME="dev-vnet"
VNET_PREFIX="192.168.0.0/16"
# subnet for the database
SUBNET_NAME="dev-sn-db"
SUBNET_PREFIX="192.168.1.0/24"
# client subnet
SUBNET2_NAME="dev-sn-client"
SUBNET2_PREFIX="192.168.2.0/24"

#network security group
NSG_NAME=$SUBNET2_NAME-nsg

## COMPUTE VM
VM_NAME="adb-vm-client"
VM_PREFERRED_SIZES=( "Standard_DS3_v2" "Standard_DC1s_v2" "Standard_DC2s_v2" "Standard_DC2ads_v5" "Standard_L4s" )
VM_IMAGE="MicrosoftWindowsDesktop:Windows-11:win11-22h2-pro:latest"

## CLOUD STORAGE
# Storage accounts require a unique name across azure. Enter your unique name below.
STORAGE_ACCOUNT_NAME="your-storage-account"
STORAGE_CONTAINER_NAME="adb-sample"

## IDENTITIES
# This identity will be used for your VM. The password will also be used for the database ADMIN user
USER_NAME="adb"
USER_PASSWORD="your-complex-password"
85 changes: 85 additions & 0 deletions azure-cli/create-adb.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# Oracle Database@Azure: Create an Autonomous Database
The steps below show how to create an Autonomous Database using the Azure CLI.

Prerequisites:
* [Install the Azure CLI](https://learn.microsoft.com/en-us/cli/azure/)
* [Subscribe to Oracle Database@Azure](https://www.youtube.com/watch?v=MEB8kB_TI2I)
* Ensure you have the appropriate user groups and privileges. See [details for onboarding Autonomous Database](https://learn.microsoft.com/en-us/azure/oracle/oracle-db/onboard-oracle-database)

## Deploy your Autonomous Database
Use the following scripts to deploy your infrastructure and Autonomous Database. You can run the scripts independently or run `create-all-resources.sh`. Simply update the [`config`](#configuration-file) prior to running the scripts:

|Script|Description|
|----|---|
|[create-resource-group.sh](create-resource-group.sh)|Create a resource group|
|[create-network.sh](create-network.sh)|Create virtual cloud network. <br><br>ADB must be deployed to a delegated subnet. In addition, ADB access is thru a private endpoint. This means it must be accessed from either the same VCN or another privileged network.|
|[create-adb.sh](create-adb.sh)|Create an Autonomous Database|
|[create-compute-vm.sh](create-compute-vm.sh)|Create a VM in that VCN|
|[create-all-resources.sh](create-all-resources.sh)|Creates your resource group, network, ADB and VM|
|[create-data-lake-storage.sh](create-data-lake-storage.sh)|Creates an Azure Data Lake Gen 2 storage account, a container and uploads sample data into that container|
|[delete-all-resources.sh](delete-all-resources.sh)|Deletes your resource group, network, ADB and VM|

### Configuration file
The Azure cli deployment scripts rely on settings found in the config file. These resources **will be created** by the scripts. Update the config file prior to running any of the scripts.

>**IMPORTANT:** This file will contain a password that is used to connect to Autonomous Database and the virtual machine. Set the file's permissions so that only the file's owner can view its contents:
```bash
chmod 600 config
```

|Setting|Description|Example|
|----|----|----|
|LOCATION|Region where resources will be deployed. [See documentation](https://docs.oracle.com/en-us/iaas/Content/database-at-azure/oaa_regions.htm) for regions where Oracle Database 23ai is available|"eastus"|
|RESOURCE_GROUP|Target resource group for new resources|"development"|
|ADB_NAME|Autonomous Database name. This name must be unique within a region location|"quickstart"|
|VNET_NAME|Virtual network|"dev-vnet"|
|VNET_PREFIX|CIDR range for the virtual network|"192.168.0.0/16"|
|SUBNET_NAME|Delegated subnet where the database will be deployed|"dev-sn-db"|
|SUBNET_PREFIX|CIDR range for the delegated subnet|"192.168.1.0/24"|
|SUBNET2_NAME|Client subnet. The VM will be deployed to this subnet|"dev-sn-client"|
|SUBNET2_PREFIX|CIDR range for the client subnet|"192.168.2.0/24"|
|NSG_NAME|Name of the network security group used by the client subnet|$SUBNET2_NAME-nsg|
|VM_NAME|Name of the virtual machine|"adb-vm-client"|
|VM_PREFERRED_SIZES|A list of VM sizes. Change these values based on region availability. The script will attempt to create a VM based on the order listed|( "Standard_GS1" "Standard_DC1s_v2" "Standard_DC2s_v2" "Standard_DC2ads_v5" "Standard_L4s" )|
|VM_IMAGE|The image used by the VM|"MicrosoftWindowsDesktop:Windows-11:win11-22h2-pro:latest"|
|STORAGE_ACCOUNT_NAME|The name of an Azure Data Lake Storage Gen 2 account. This name must be unique across Azure. Sample data files will be uploaded into this storage account.|"mytenancysamplestorageaccount"|
|STORAGE_CONTAINER_NAME|The name of the container where files will be uploaded|"adb-sample"|
|USER_NAME|The name of the user for the virtual machine|"adb"|
|USER_PASSWORD|The password for both the VM and the Autonomous Database admin user|"Welcome1234#abcd"|

### Using the scripts
Log into azure: after updating the config file:

```bash
az login
```
Then, run your scripts. The following will deploy a complete environment, but you can also install independent components. Just make sure you install dependencies (e.g. a VCN prior to Autonomous Database):

Creating all of the resources will take approximately 15-20 minutes.

```bash
./create-all-resources.sh
```

Check for errors after running the script. For example, VM availability can impact the success of creating the resource. If there is an issue, simply rerun the script that creates the resource (note: you may need to update the config file).

## What's next
Connect to your Autonomous Database!
* [Learn about connectivity options](https://docs.oracle.com/en/cloud/paas/autonomous-database/serverless/adbsb/connect-preparing.html)
* Use these great VS Code extensions that help you develop and debug your database apps:
* SQL Developer for VS Code ([Learn More](https://www.oracle.com/database/sqldeveloper/vscode/) | [Marketplace](https://marketplace.visualstudio.com/items?itemName=Oracle.sql-developer))
* Oracle Developer Tools for VS Code ([Learn More](https://docs.oracle.com/en/database/oracle/developer-tools-for-vscode/getting-started/gettingstarted.html) | [Marketplace](https://marketplace.visualstudio.com/items?itemName=Oracle.oracledevtools))

#### JDBC Example:
JDBC is a common way to connect to Autonomous Database. For example, you can use the **Custom JDBC URL** in the VS Code SQL Developer Extension:
![connection dialog](images/connect-dialog.png)

Notice the `jdbc:oracle:thin:@` prefix followed by a connection string. You can find the connection string in different ways.

1. Go to your Autonomous Database blade in the Azure Portal and go to **Settings -> Connections**:
![Azure Portal connections](images/connections-portal.png)
2. Use the Azure cli script [`show-adb-info.sh`](./show-adb-info.sh). That script will return information about your Autonomous Database, including connection details.

<hr>
Copyright (c) 2024 Oracle and/or its affiliates.<br>
Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
37 changes: 37 additions & 0 deletions azure-cli/create-adb.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash

# Copyright (c) 2024 Oracle and/or its affiliates.
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/

echo ""
echo "##"
echo "# deploy autonomous database"
echo "##"
echo ""
# ensure you update the config file to match your deployment prior to running the deployment

source ./config

# ADB requires the IDs of the networking components
VNET_ID=$(az network vnet show --resource-group $RESOURCE_GROUP --name $VNET_NAME --query id -o tsv)
SUBNET_ID=$(az network vnet subnet show --resource-group $RESOURCE_GROUP --vnet-name $VNET_NAME --name $SUBNET_NAME --query id -o tsv)

# create the database
az oracle-database autonomous-database create \
--location $LOCATION \
--autonomousdatabasename $ADB_NAME \
--resource-group $RESOURCE_GROUP \
--vnet-id $VNET_ID \
--subnet-id $SUBNET_ID \
--display-name $ADB_NAME \
--compute-model ECPU \
--compute-count 2 \
--cpu-auto-scaling true \
--data-storage-size-in-gbs 500 \
--store-auto-scaling true \
--backup-retention-period-in-days 7 \
--license-model BringYourOwnLicense \
--db-workload OLTP \
--db-version 23ai \
--regular \
--admin-password $USER_PASSWORD
10 changes: 10 additions & 0 deletions azure-cli/create-all-resources.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright (c) 2024 Oracle and/or its affiliates.
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/

set -e

./create-resource-group.sh
./create-network.sh
./create-adb.sh
./create-data-lake-storage.sh
./create-compute-vm.sh
71 changes: 71 additions & 0 deletions azure-cli/create-compute-vm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#!/bin/bash
# Copyright (c) 2024 Oracle and/or its affiliates.
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/

echo ""
echo "##"
echo "# deploy compute vm"
echo "##"
echo ""

# ensure you update the config file to match your deployment prior to running the deployment
source ./config

VM_SIZE=""
IP_PUBLIC="${VM_NAME}-pip"
NIC_NAME="${VM_NAME}-nic"

# Function to find the first available size from the priority list
find_available_size() {

#availableSizes=$(az vm list-sizes --location $LOCATION --query "[].name" -o tsv)
availableSizes=$(az vm list-skus --location $LOCATION --resource-type virtualMachines --query "[?restrictions[?reasonCode=='NotAvailableForSubscription']].name" -o tsv)

for size in "${VM_PREFERRED_SIZES[@]}"
do
echo ""
echo "search for $size"
echo ""
if echo "$availableSizes" | grep -q "$size"; then
echo ""
echo "VM size $size is available in $LOCATION. Let's create the VM."
VM_SIZE=$size
break
fi
done
}

# check if there are any available VMs
find_available_size

# if no VMs are available - bail.
if [ -z $VM_SIZE ]; then
echo "No capacity for your VM sizes in $LOCATION. Unable to create a compute VM"
exit -1
fi

# Create a public IP address for the VM
az network public-ip create \
--resource-group $RESOURCE_GROUP \
--name $IP_PUBLIC \
--sku Standard

# Create a virtual NIC and associate with public IP address and NSG
az network nic create \
--resource-group $RESOURCE_GROUP \
--name $NIC_NAME \
--vnet-name $VNET_NAME \
--subnet $SUBNET2_NAME \
--public-ip-address $IP_PUBLIC \
--network-security-group $NSG_NAME

# Create a virtual machine
az vm create \
--resource-group $RESOURCE_GROUP \
--name $VM_NAME \
--image $VM_IMAGE \
--size $VM_SIZE \
--admin-username $USER_NAME \
--admin-password $USER_PASSWORD \
--generate-ssh-keys \
--nics $NIC_NAME
Loading