Explanation: To complete the task of setting up the context for Fn CLI and deploying the python function to exam-app, you can follow these steps:
a. Set up the Fn CLI context in Cloud Shell - In the OCI Console, go toDeveloper Servicesand clickFunctions. - Select your assigned compartment from the list on the left. - ClickGetting Startedon the top right corner. - Copy and paste the commands from theSet Up Fn CLI Contextsection into the Cloud Shell window. This will create a new context for your region and compartment. - Set your registry [repo-name-prefix] by entering the following command in the Cloud Shell window:
`fn update context registry [region_key].ocir.io/[tenancy-name]/{username}`
where [region_key] is the region key for your region (for example, iad for US East Ashburn), [tenancy-name] is the name of your tenancy (for example, ocuocictrng16), and {username} is your username (for example, 99248134-lab.user01).
For example, if your region is US East Ashburn, your tenancy is ocuocictrng16, and your username is 99248134-lab.user01, your command would be:
`fn update context registry iad.ocir.io/ocuocictrng16/99248134-lab.user01`
b. Login to the registry using docker login, which will require you to generate and use an Auth Token - To generate an Auth Token, follow these steps: - In the OCI Console, open the Profile menu on the top right corner and clickUser Settings. - ClickAuth Tokenson the left panel and then clickGenerate Token. - Enter a description for the token and clickGenerate Token. - Copy and save the token value. You will not be able to see it again later. - To login to the registry using docker login, follow these steps: - In the Cloud Shell window, enter the following command:
`docker login [region_key].ocir.io`
where [region_key] is the region key for your region (for example, iad for US East Ashburn).
For example, if your region is US East Ashburn, your command would be:
`docker login iad.ocir.io`
- Enter your username in the format `[tenancy-name]/oracleidentitycloudservice/{username}` (for example, ocuocictrng16/oracleidentitycloudservice/99248134-lab.user01) and press Enter.
- Enter your Auth Token as the password and press Enter. You should see a message saying "Login Succeeded".
c. Use wget https://objectstorage.us-ashburn1.oraclecloud.com/n/ocuocictrng5/b/PBT_Storage/o/ExamFunction-main.zipto upload the zip archive containing the Python function files to Cloud Shell. - In the Cloud Shell window, enter the following command:
`wget https://objectstorage.us-ashburn1.oraclecloud.com/n/ocuocictrng5/b/PBT_Storage/o/ExamFunction-main.zip`
This will download the zip archive to your current directory.
d. Extract the files by using the unzip utility and navigate to the python sub-folder - In the Cloud Shell window, enter the following commands:
`unzip ExamFunction-main.zip`
`cd ExamFunction-main/python`
This will extract the files from the zip archive and change your current directory to the python sub-folder.
e. Deploy the python function to the exam-app using an fn command - In the Cloud Shell window, enter the following command:
`fn deploy --app exam-app --local`
This will deploy the python function to the exam-app application using your local Docker image.
f. Invoke the function at least 2 times using an fn command - In the Cloud Shell window, enter the following command:
`fn invoke exam-app hellopython`
This will invoke the function and print its output.
- You can invoke the function again by repeating the same command or pressing Up Arrow and Enter keys. You should see different outputs each time you invoke the function.