Skip to content

Made this a multicloud sample #6

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

Merged
merged 4 commits into from
Dec 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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ Temporary Items
.key
.crt
.csr
.pem
.pem
replace-default-config.sh
22 changes: 13 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,32 @@
# Oracle Database@Azure Samples
# Oracle Autonomous Database Samples

[![License: UPL](https://img.shields.io/badge/license-UPL-green)](https://img.shields.io/badge/license-UPL-green)

## Introduction
Oracle Database@Azure brings Oracle's best databases - Exadata and Autonomous Database - to Microsoft Azure as a native Azure services. Modernize and deliver powerful new apps that leverage Oracle Database 23ai and Azure services:
* Build new cloud native apps using Azure services, such as Azure Kubernetes and Azure OpenAI, with Oracle Autonomous Database.
Oracle Autonomous Database provides a fully automated cloud database service that eliminates manual database management tasks, reduces operational costs, enhances security through automatic patching and encryption, and enables businesses to rapidly scale and optimize their data processing and analytics.

Autonomous Database runs natively on OCI, Azure (Oracle Database@Azure) and Google Cloud (Oracle Database@Google Cloud). Modernize and deliver powerful new apps that leverage Oracle Database 23ai with other cloud services services:
* Build new cloud native apps using built-in integrations, such as Kubernetes, AI, DevOps and more
* Enhance existing apps with natural language and other generative AI capabilities.
* Quickly react to business demands using one converged, fully automated database that’s optimized for all workloads and data formats.

Use these samples to deploy Autonomous Database on cloud providers using APIs. Then, check out the SQL samples that leverage both Autonomous Database cloud integration and converged database capabiltities.

## Getting Started
* [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/README.md)
* Deploy Autonomous Database:
* [On OCI](./multicloud/oci-cli/README.md)
* [On Azure](./multicloud/azure-cli/README.md)
* On Google Cloud (deployment script coming soon)
* 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/README.md)
* Create a database user and add sample data
* Work with data in Azure Storage
* Work with data in cloud storage
* Get started with Select AI
* Build property graphs and run analytics over those graphs
* .... and more

<!--
Expand Down
22 changes: 0 additions & 22 deletions azure-cli/deploy-adb.sh

This file was deleted.

11 changes: 8 additions & 3 deletions azure-cli/README.md → multicloud/azure-cli/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
# Oracle Database@Azure: Create an Autonomous Database
There are different ways that you can 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

The steps below show how to create an Autonomous Database using the Azure CLI.

Prerequisites:
## 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)
Expand Down Expand Up @@ -72,12 +77,12 @@ Connect to your Autonomous Database!

#### 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)
![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)
![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>
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

echo ""
echo "##"
echo "# deploy autonomous database"
echo "# create autonomous database"
echo "##"
echo ""
# ensure you update the config file to match your deployment prior to running the deployment
Expand All @@ -25,7 +25,7 @@ az oracle-database autonomous-database create \
--subnet-id $SUBNET_ID \
--display-name $ADB_NAME \
--compute-model ECPU \
--compute-count 2 \
--compute-count 4 \
--cpu-auto-scaling true \
--data-storage-size-in-gbs 500 \
--store-auto-scaling true \
Expand Down
File renamed without changes.
File renamed without changes.
75 changes: 75 additions & 0 deletions multicloud/oci-cli/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Create an Autonomous Database on OCI
There are different ways that you can deploy a new Oracle Autonomous Database:
* [Using the OCI Console](https://youtu.be/5BUXoBewZbQ)
* [Using Terraform scripts](https://github.com/oci-landing-zones/terraform-oci-multicloud-azure/tree/main)
* Using the OCI CLI

The steps below show how to create an Autonomous Database using the OCI CLI.

## Prerequisites:
* [Install the OCI CLI](https://docs.oracle.com/en-us/iaas/Content/API/SDKDocs/cliinstall.htm)
* [Subscribe to Autonomous Database for free](https://www.oracle.com/autonomous-database/free-trial/)
* See documentation to ensure you have the appropriate user groups and privileges.
* [Deploy Autonomous Database](https://docs.oracle.com/en/cloud/paas/autonomous-database/serverless/adbsb/autonomous-database-iam-policies.html)
* [Use OCI GenAI](https://docs.oracle.com/en-us/iaas/Content/generative-ai/iam-policies.htm)
* [Use OCI Object Storage](https://docs.oracle.com/en-us/iaas/Content/Security/Reference/objectstorage_security.htm#iam-policies)

## Deploy your Autonomous Database
Use the following scripts to deploy your Autonomous Database and sample data. 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-compartment.sh](create-compartment-group.sh)|Create a compartment for your Autonomous Database|
|[create-adb.sh](create-adb.sh)|Create an Autonomous Database in the compartment|
|[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 OCI Object Storage bucket and uploads sample data into that bucket|
|[delete-all-resources.sh](delete-all-resources.sh)|Deletes your compartment, bucket and Autonomous Database|

### Configuration file
The OCI 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|
|----|----|----|
|TENANCY_OCID|The tenancy Oracle Cloud Identifier. [See documentation](https://docs.oracle.com/en-us/iaas/Content/Identity/tenancy/Viewing_the_Tenancy_Details_Page.htm) for finding the OCID. |"ocid1.tenancy.oc1..aaaaaaaa..."|
|REGION|Region where resources will be deployed. Your tenancy must be subscribed to the region.|"us-ashburn-1"|
|COMPARTMENT|Target compartment for new resources|"development"|
|ADB_NAME|Autonomous Database name. This name must be unique within a region location|"quickstart"|
|BUCKET_NAME|The name of the Object Storage bucket where files will be uploaded|"adb-sample"|
|USER_PASSWORD|The password for the Autonomous Database admin user|"Welcome1234#abcd"|

### Using the scripts
Open a command prompt to deploy all the resources.

Creating all of the resources will take approximately 5 minutes.

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

Check for errors after running the script. 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/
16 changes: 16 additions & 0 deletions multicloud/oci-cli/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# 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.
TENANCY_OCID="ocid1.tenancy.oc1..aaaaaaaafcue47pqmrf4vigneebgbcmmoy5r7xvoypicjqqge32ewnrcyx2a"
REGION="us-ashburn-1"
COMPARTMENT_NAME="from-github"
ADB_NAME="quickstart"

## CLOUD STORAGE
# Buckets require a unique name within a region. Enter your unique name below.
BUCKET_NAME="adb-sample"

## IDENTITIES
# The password is for the ADB ADMIN user. It must be between 12 and 30 characters long and must include at least one uppercase letter, one lowercase letter, and one numeric character
USER_PASSWORD="bigdataPM2019#"
16 changes: 16 additions & 0 deletions multicloud/oci-cli/config.default
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# 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.
TENANCY_OCID="your-tenancy-ocid"
REGION="us-ashburn-1"
COMPARTMENT_NAME="your-target-compartment"
ADB_NAME="quickstart"

## CLOUD STORAGE
# Buckets require a unique name within a region. Enter your unique name below.
BUCKET_NAME="adb-sample"

## IDENTITIES
# The password is for the ADB ADMIN user. It must be between 12 and 30 characters long and must include at least one uppercase letter, one lowercase letter, and one numeric character
USER_PASSWORD=""
31 changes: 31 additions & 0 deletions multicloud/oci-cli/create-adb.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# 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 "# create autonomous database"
echo "##"
echo ""
# ensure you update the config file to match your deployment prior to running the deployment

source ./config

COMPARTMENT_OCID=`oci iam compartment list --all --region $REGION --query "data[?name=='$COMPARTMENT_NAME' && \"lifecycle-state\"=='ACTIVE'].id | [0]" --raw-output`

oci db autonomous-database create \
--region $REGION \
--compartment-id $COMPARTMENT_OCID \
--db-name $ADB_NAME \
--display-name $ADB_NAME \
--compute-model ECPU \
--compute-count 4 \
--is-auto-scaling-enabled true \
--data-storage-size-in-gbs 500 \
--is-auto-scaling-for-storage-enabled true \
--backup-retention-period-in-days 7 \
--db-workload OLTP \
--db-version 23ai \
--display-name $ADB_NAME \
--whitelisted-ips '["0.0.0.0/0"]' \
--is-mtls-connection-required false \
--admin-password $USER_PASSWORD
8 changes: 8 additions & 0 deletions multicloud/oci-cli/create-all-resources.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# 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-compartment.sh
./create-adb.sh
./create-data-lake-storage.sh
12 changes: 12 additions & 0 deletions multicloud/oci-cli/create-compartment.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# 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 "# create a compartment"
echo "##"
echo ""
# ensure you update the config file to match your deployment prior to running the deployment
source ./config

oci iam compartment create --region $REGION --compartment-id $TENANCY_OCID --name "$COMPARTMENT_NAME" --description "Created by oracle-autonomous-database-samples"
38 changes: 38 additions & 0 deletions multicloud/oci-cli/create-data-lake-storage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/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 "# Create an object storage bucket with sample data"
echo "##"
echo ""
# ensure you update the config file to match your deployment prior to running the deployment

source config

echo "# Creating bucket $BUCKET_NAME"
COMPARTMENT_OCID=`oci iam compartment list --region $REGION --all --query "data[?name=='$COMPARTMENT_NAME' && \"lifecycle-state\"=='ACTIVE'].id | [0]" --raw-output`

oci os bucket create --region $REGION --compartment-id $COMPARTMENT_OCID --name $BUCKET_NAME

echo "# Uploading sample files"

echo "Example support site files"
oci os object bulk-upload --region $REGION --bucket-name $BUCKET_NAME --src-dir ../../sql/support-site --prefix "support-site/" --overwrite

echo "Example data files"
oci os object bulk-upload --region $REGION --bucket-name $BUCKET_NAME --src-dir ../../sql/data --prefix "data/" --overwrite

echo "Done."
echo ""
echo "Uploaded files:"
oci os object list --region $REGION --bucket-name $BUCKET_NAME --query 'data[*].{Name:"name", "Size":"size"}' --output table

echo ""
echo "Region: $REGION"
echo "Bucket: $BUCKET_NAME"
echo "Storage URL prefix:"
NAMESPACE=`oci os ns get --query "data" --raw-output`
echo "https://$NAMESPACE.objectstorage.$REGION.oci.customer-oci.com/n/$NAMESPACE/b/$BUCKET_NAME/o"
echo ""
23 changes: 23 additions & 0 deletions multicloud/oci-cli/delete-adb.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/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/

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

source ./config

# Ask for confirmation
echo "Are you sure you want to delete database '$ADB_NAME' in region '$REGION', compartment '$COMPARTMENT_NAME'?"
echo "Enter (y/n)"
read confirmation

if [[ $confirmation == [yY] || $confirmation == [yY][eE][sS] ]]; then
echo "Deleting Autonomous Database"
COMPARTMENT_OCID=`oci iam compartment list --region $REGION --all --query "data[?name=='$COMPARTMENT_NAME' && \"lifecycle-state\"=='ACTIVE'].id | [0]" --raw-output`
ADB_OCID=`oci db autonomous-database list --region $REGION --compartment-id $COMPARTMENT_OCID --query "data[?\"db-name\"=='$ADB_NAME' && \"lifecycle-state\"=='AVAILABLE'].id | [0]" --raw-output`

oci db autonomous-database delete --region $REGION --force --autonomous-database-id $ADB_OCID --wait-for-state TERMINATED
else
echo "Deletion cancelled. The database was not deleted."
fi
42 changes: 42 additions & 0 deletions multicloud/oci-cli/delete-all-resources.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/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/

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

source ./config

# Ask for confirmation
echo ""
echo "Are you sure you want to delete the sample resources?"
echo "- ADB: $ADB_NAME"
echo "- Bucket: $BUCKET_NAME"
echo "- Compartment: $COMPARTMENT_NAME"
echo ""
echo "Enter (y/n)"
read confirmation

if [[ $confirmation == [yY] || $confirmation == [yY][eE][sS] ]]; then
echo "Deleting Autonomous Database"
COMPARTMENT_OCID=`oci iam compartment list --region $REGION --all --query "data[?name=='$COMPARTMENT_NAME' && \"lifecycle-state\"=='ACTIVE'].id | [0]" --raw-output`
ADB_OCID=`oci db autonomous-database list --region $REGION --compartment-id $COMPARTMENT_OCID --query "data[?\"db-name\"=='$ADB_NAME' && \"lifecycle-state\"=='AVAILABLE'].id | [0]" --raw-output`

oci db autonomous-database delete --region $REGION --force --autonomous-database-id $ADB_OCID --wait-for-state SUCCEEDED

if [ $? -eq 0 ]; then
echo "Database '$ADB_NAME' has been successfully deleted."
fi

echo "Deleting Object Storage bucket"
oci os bucket delete --region $REGION --bucket-name $BUCKET_NAME --force --empty

echo "Deleting compartment $COMPARTMENT_NAME"
oci iam compartment delete --compartment-id $COMPARTMENT_OCID --force --wait-for-state SUCCEEDED

if [ $? -eq 0 ]; then
echo "Resources deleted."
fi
else
echo "Deletion cancelled."
fi
Loading