oracle cloud⚓︎
Resources
Installation⚓︎
Install with interactive installation:
sudo bash -c "$(curl -L https://raw.githubusercontent.com/oracle/oci-cli/master/scripts/install/install.sh)"
$HOME
) for consistency.
Test your installation:
oci --version
Configure the CLI with oci setup config
; the prompts will ask for
- your
.oci/config
file location - your user's OCID, tenancy's OCID, API Key fingerprint and region
Test the connection with
oci os ns get # It returns the tenancy's namespaces
Error
Troubleshoot the NotAuthenticated
error with this blog post.
Check shape availability⚓︎
Get the list of compartments with
oci iam compartment list
Info
The output of the CLI are JSON records (readability is improved using --output table
). Save them in a variable with VARIABLENAME=$(oci ...)
then parse them in bash with jq using echo $VARIABLENAME | jq '.'
Get the list of compartments' OCIDs into an array:
COMPARTMENTS=$(oci iam compartment list)
echo $COMPARTMENTS > compartments.json
COMPARTMENTS_OCID=$(cat compartments.json | jq -r '.data[].id')
COMPARTMENT_ARRAY=($(echo $COMPARTMENTS_OCID | tr " " "\n"))
rm compartments.json
You can access them with a for
loop like:
for compartment_ocid in "${COMPARTMENT_ARRAY[@]}"
do
echo $compartment_ocid
done
Using the same for
loop as above, get the list of available instance shapes (reference). The grep
part is used to check if a specific shape is available in each compartment:
for compartment_ocid in "${COMPARTMENT_ARRAY[@]}"
do
SHAPE=$(oci compute shape list --compartment-id $compartment_ocid | grep "VM.Standard.A1.Flex")
# Check if shape is available
if [ -z "$SHAPE" ]
then
echo "No shape found in compartment $compartment_ocid"
else
echo $SHAPE
fi
done
Next: create a .NET worker service with the .NET SDK (documentation also available here)