Oracle by Example branding Consuming Oracle MySQL Cloud Service RESTful Resources by Using C#

part 0Before You Begin

This lab shows you how to consume Oracle MySQL Cloud Service administrative RESTful resources by using C#.

Background

With Oracle MySQL Cloud Service, you can deploy MySQL servers to the cloud, with each deployment containing a single MySQL server. You have full access to the features and operations available with MySQL server. To simplify maintenance and management operations, Oracle provides computing power, physical storage, and tooling; and it exposes administrative RESTful resources that you can use to develop applications.

What Do You Need?

  • A desktop or laptop computer running Microsoft Windows 7 or later
  • Access to an instance of Oracle MySQL Cloud Service
  • Microsoft Visual Studio 2010 express for windows desktop or later
  • net-mysql-obelab.zip downloaded to your computer

part 1Gather the Service Parameters from Your MySQL Instance

  1. Sign in to your Oracle Cloud account and change the temporary password, if you haven't already done so.
  2. Log in to your Cloud instance.
  3. Click Dashboard.
  4. Click Customize Dashboard.
  5. Select Show for MySQL Cloud Service, and close the dialog box.
  6. On the Oracle MySQL Cloud Service tile, click the Action menu action menu and select View Details.
  7. On the Service Details page, make a note of the following service parameters:
    • Identity Domain Id
    • REST Endpoint
    • Service Name (Click the Open Service Console button.)
    Oracle MySQL Cloud Service Details
    Description of the illustration mysql-service-details.png

part 2Try the Sample Application

  1. Extract the sample code from the downloaded net-mysql-obelab.zip file.
  2. In Visual Studio, open the configuration file and replace the following keys:
    • identityDomain value key with your Identity Domain Id
    • resourceURI value key with the REST endpoint URL
  3. Append the following to the REST endpoint URL, where TestCorp is your Identity Domain Id and MyTestInstance is your service name: /paas/api/v1.1/instancemgmt/TestCorp/services/MySQLCS/instances/MyTestInstance/accessrules
  4. In Visual Studio, build and run the solution.

    The response looks like the following:

    
     Waiting for response from the server...
    {"accessRules":[{"ruleName":"ora_p2admin_ssh","description":"Permit public access to SSH port","status":"enabled","source":"PUBLIC-INTERNET",
                     "destination":"mysql_MASTER","ports":"22","protocol":"tcp","ruleType":"DEFAULT"},
                    {"ruleName":"ora_p2admin_mysql","description":"Permit public access to MySQL port","status":"enabled","source":"PUBLIC-INTERNET",
                     "destination":"mysql_MASTER","ports":"3306","protocol":"tcp","ruleType":"DEFAULT"},
                    {"ruleName":"ora_trusted_hosts_mysql","description":"DO NOT MODIFY: Permit specific IPs to access MySQL port ","status":"enabled","source":"127.0.0.1\/32",
                     "destination":"mysql_MASTER","ports":"3306","protocol":"tcp","ruleType":"SYSTEM"},
                    {"ruleName":"ora_p2admin_em","description":"Permit public access to Enterprise Monitor https port","status":"disabled",
                     "source":"PUBLIC-INTERNET","destination":"mysql_MASTER","ports":"18443","protocol":"tcp","ruleType":"DEFAULT"},
                    {"ruleName":"sys_infra2mys_admin_ssh","description":"DO NOT MODIFY: Permit PSM to ssh to admin host","status":"enabled","source":"PAAS-INFRA",
                     "destination":"mysql_ADMIN_HOST","ports":"22","protocol":"tcp","ruleType":"SYSTEM"}],"activities":[]}
    Press any key to finish
    

more informationWant to Learn More?