If one or more OCI Functions users is not a tenancy administrator:
Sign in to the Console as a tenancy administrator.
Open the navigation menu and select Identity & Security. Under Identity, select Policies.
Select Create Policy, specify a name and description for the new policy, and select the tenancy's root compartment.
Use the Policy Builder to create the policy. Select Functions from the list of Policy use cases, and base the policy on the policy template Let users create, deploy, and manage functions and applications.
The policy template includes the following policy statements:
Allow group <group-name> to use cloud-shell in tenancy
Allow group <group-name> to manage repos in tenancy
Allow group <group-name> to read objectstorage-namespaces in tenancy
Allow group <group-name> to manage logging-family in tenancy
Allow group <group-name> to read metrics in tenancy
Allow group <group-name> to manage functions-family in tenancy
Allow group <group-name> to use virtual-network-family in tenancy
Allow group <group-name> to use apm-domains in tenancy
Allow group <group-name> to read vaults in tenancy
Allow group <group-name> to use keys in tenancy
Allow service faas to use apm-domains in tenancy
Allow service faas to read repos in tenancy where request.operation='ListContainerImageSignatures'
Allow service faas to {KEY_READ} in tenancy where request.operation='GetKeyVersion'
Allow service faas to {KEY_VERIFY} in tenancy where request.operation='Verify'
If necessary, you can restrict these policy statements by compartment.
Open the navigation menu and select Developer Services. Under Functions, select Applications.
Select the region you're using with OCI Functions.
Select Create Application.
Specify:
helloworld-app as the name for the new application. You'll deploy your first function in this application, and specify this application when invoking the function.
The VCN and subnet in which to run the function. Note that a public subnet requires an internet gateway in the VCN, and a private subnet requires a service gateway in the VCN.
In a terminal window in your development environment:
Confirm that Docker is installed by entering:
Copy
docker version
If you see an error message indicating that Docker is not installed, you have to install Docker before proceeding. See the Docker documentation for your platform (for Oracle Linux, see here).
Assuming Docker is installed, go to the Prerequisites section of the Fn Project home page on GitHub and confirm that the installed version of Docker is at least the minimum version specified there. If not, re-install Docker before proceeding.
Launch the standard hello-world Docker image as a container to confirm that Docker is running by entering:
Copy
docker run hello-world
If you see an error message indicating that Docker is not running, you have to start the Docker daemon before proceeding. See the Docker documentation.
Note that you specify --provider oracle-ip to enable authentication and authorization using instance OCIDs, dynamic groups, and policies granting permissions to those dynamic groups.
Specify that the Fn Project CLI is to use the new context by entering:
Configure the new context with the api-url endpoint to use when calling the OCI API by entering:
Copy
fn update context api-url <api-endpoint>
where <api-endpoint> is one of the endpoints in the list of Functions endpoints in the Functions API, in the format https://functions.<region-identifier>.oci.oraclecloud.com. For example:
Configure the Fn Project CLI context with the Oracle Cloud Infrastructure Registry address in the current region and tenancy that you want to use with OCI Functions:
where <repo-name-prefix> is a prefix of your choosing for the Oracle Cloud Infrastructure Registry repository in which to store images for the function. For example:
Configure the Fn Project CLI context with the OCID of the compartment for repositories to and from which you want OCI Functions to push and pull function images, by entering:
Change directory to the hello-java directory created in the previous step:
cd hello-java
Enter the following single Fn Project command to build the function and its dependencies as a Docker image called hello-java, push the image to the specified Docker registry, and deploy the function to OCI Functions in the helloworld-app application that you created earlier:
fn -v deploy --app helloworld-app
(Optional) Confirm that the function has been deployed to OCI Functions by selecting Functions (under Resources on the details page for the helloworld-app application) and noting that the hello-java function now appears.