Skip to the content.

Go to Overview Page

Building Multi-Cloud Apps

Developing an ASP.NET App for ADB (on Azure VM)

Introduction

Interest in using Oracle Autonomous Database (ADB) is high. In fact, many developers ask how to connect their App Tier on Azure to ADB. Let’s first build a basic ASP.NET Web application in Visual Studio that connects to ADB. You will be using Visual Studio 2017, but steps in other Visual Studio versions should be similar. You will use managed ODP.NET for data access between the application and database, but ODP.NET Core should work as well with these instructions.

Let’s get started.

Steps

STEP 1: Install Visual Studio

Full installation guide of Visual Studio you can find here.

STEP 2: Create a new ASP.NET Web Application

These files constitute a web page that connects to ADB and returns the database version it is using to demonstrate basic connectivity.

//Enter in the user id and password.

string conString = "User Id=<USER ID>;Password=<PASSWORD>;";

Example: string conString = "User Id=ADMIN;Password=WElcome_123#;";

//Enter port, host name or IP, service name, and wallet directory for your Oracle Autonomous DB.

conString += "Data Source=(description=(address=(protocol=tcps)(port=<PORT>)(host=<HOSTNAME OR IP>))(connect_data=(service_name=<SERVICE NAME>))(SECURITY = (MY_WALLET_DIRECTORY = <DIRECTORY LOCATION>)));";

Example: 
conString += "Data Source=(description=(address=(protocol=tcps)(port=1522)(host=adb.uk-london-1.oraclecloud.com))(connect_data=(service_name=d4qvm7rtgjikgr5_myautonomousdb_high.atp.oraclecloud.com))(SECURITY = (MY_WALLET_DIRECTORY = C:\\Users\\myadmin\\source\\repos\\MyWebApp)));";

You will find these entries in the tnsnames.ora file from Wallet_MyAutonomousDB.zip downloaded in the previous lab. The wallet directory must be set to the local machine directory where your ADB wallet file will reside. For this tutorial, you will copy the wallet zip file to the web project’s root directory.

In this example C:\\Users\\myadmin\\source\\repos\\MyWebApp.

Additionally, add the wallet file, cwallet.sso, from the credentials zip file to the web project root directory in line with the MY_WALLET_DIRECTORY setting.

STEP 3: Install WebServer (IIS)

STEP 4: Run your .NET Web Application

Congratulations, you are now ready to move to the next lab.


Go to Overview Page