Use Resource Principal with DBMS_CLOUD

When you specify a resource principal credentials in DBMS_CLOUD calls, the database authenticates the Oracle Cloud Infrastructure requests for you and the database provides the credentials to access to the resources.

If you have not already done so, perform the required prerequisite steps:

To use a DBMS_CLOUD procedure with resource principal credentials:

  1. Use a DBMS_CLOUD procedure or function and specify OCI$RESOURCE_PRINCIPAL as the credential name.

    For example, you can access the Oracle Cloud Infrastructure Object Storage using resource principal credentials:

    CREATE TABLE CHANNELS
       (channel_id CHAR(1),
        channel_desc VARCHAR2(20),
        channel_class VARCHAR2(20)
       );
    /
    
    BEGIN
     DBMS_CLOUD.COPY_DATA(
        table_name =>'CHANNELS',
        credential_name =>'OCI$RESOURCE_PRINCIPAL',
        file_uri_list =>'https://objectstorage.us-phoenix-1.oraclecloud.com/n/namespace-string/b/bucketname/o/channels.txt',
        format => json_object('delimiter' value ',')
     );
    END;
    /
    

If you compare the steps required to access Object Storage as shown in Create Credentials and Copy Data into an Existing Table, notice that Step 1, creating credentials is not required when you use resource principal because you are using the system defined OCI$RESOURCE_PRINCIPAL credentials.