Create Instance using CLI command for BTP Cloud Integration

Estimated read time 6 min read

The CPI trial comes with a time limit and gets deleted once the time limit is crossed. You’ll have to perform all tasks again when you subscribe after deletion. One of the tasks is to create instances.

Let us say you want to create service instance for plan api and integration-flow. Usually we use btp cockpit to create it and it is easy to set up. What if you have to repeat the same, once trial tenant is deleted. Creating instances using commands can be easy and we can run the same command every time we set up the trial account.

Usually we need three instances creation for setting up the trial tenant to get started with development.

Plan api ( access cloud integration artifacts)Plan integration-flow ( sending message to cpi flow)Plan apiportal-apiaccess ( accessing APIM artifacts )

I am making use of CLI command for creating the instances. 

Install CLI command

https://help.sap.com/docs/btp/sap-business-technology-platform/download-and-install-cloud-foundry-command-line-interface

Once installed check if it is available

 

or you can make use of SAP business application studio and it comes with installed cf

https://help.sap.com/docs/bas/sap-business-application-studio/terminal

Login

When you log in for the first time, you need to add your api endpoint. You will find it in the BTP cockpit.

Click on the link shown in the terminal. 

login with your user

copy this key and paste it in your terminal

 

My space is dev and all the instances will be created under dev space.

Create instance for plan api

When you create instance we need to provide some parameters and these parameters are kept in json format. Instead of complicating things, First we create a one instance using BTP cockpit ui. Let us call it test_blog and I have assigned one role once create this is how it looks like

Copy the json file and put it in the folder and file name is instance-api.json

Json

{
“grant-types”: [
“client_credentials”
],
“redirect-uris”: [],
“roles”: [
“AuthGroup_IntegrationDeveloper”
],
“token-validity”: 43200
}

Now we will use json as parameter file for creating a new instance.

cf create-service it-rt api odata-api -c instance-api.json
cf create-service-key odata-api key-01

 

Create instance for plan integration-flow

Repeat the same step here as well to get the json file.

json file

{
“grant-types”: [
“client_credentials”
],
“redirect-uris”: [],
“roles”: [
“ESBMessaging.send”
],
“token-validity”: 3600
}

 

Iflow
cf create-service it-rt integration-flow iflow_blog -c instance-integration-flow.json
cf create-service-key iflow_blog key-01

 

You can view the instance and key.

 

https://help.sap.com/docs/integration-suite/sap-integration-suite/specifying-service-instance-and-service-key-parameters-in-json-format

APIM plan apiportal-apiaccess

Json

{
“role”: “APIPortal.Administrator”
}

 

cf create-service apimanagement-apiportal-trial apiportal-apiaccess apim_odata -c instance-api-access.json
cf create-service-key apim_odata key-01

https://help.sap.com/docs/integration-suite/sap-integration-suite/api-access-plan-for-api-portal

Please be aware sometimes btp trial is giving error when creating this instance be it from cockpit or from terminal. I had a issue and posted here and after sometime it starts working again. 
https://community.sap.com/t5/technology-q-a/instance-creation-for-apiportal-apiaccess-plan-in-btp-trial-fails/qaq-p/14088211

View Keys

Once you are done with creating keys you can run this command to view the keys.

cf service-key odata-api key-01

Conclusion

Once you are done with settting up the commands, next time trial account is deleleted, you can make use of the commands instead of creating them from btp cockpit. 

 

​ The CPI trial comes with a time limit and gets deleted once the time limit is crossed. You’ll have to perform all tasks again when you subscribe after deletion. One of the tasks is to create instances.Let us say you want to create service instance for plan api and integration-flow. Usually we use btp cockpit to create it and it is easy to set up. What if you have to repeat the same, once trial tenant is deleted. Creating instances using commands can be easy and we can run the same command every time we set up the trial account.Usually we need three instances creation for setting up the trial tenant to get started with development.Plan api ( access cloud integration artifacts)Plan integration-flow ( sending message to cpi flow)Plan apiportal-apiaccess ( accessing APIM artifacts )I am making use of CLI command for creating the instances. Install CLI commandhttps://help.sap.com/docs/btp/sap-business-technology-platform/download-and-install-cloud-foundry-command-line-interfaceOnce installed check if it is available or you can make use of SAP business application studio and it comes with installed cfhttps://help.sap.com/docs/bas/sap-business-application-studio/terminalLoginWhen you log in for the first time, you need to add your api endpoint. You will find it in the BTP cockpit.Click on the link shown in the terminal. login with your usercopy this key and paste it in your terminal My space is dev and all the instances will be created under dev space.Create instance for plan apiWhen you create instance we need to provide some parameters and these parameters are kept in json format. Instead of complicating things, First we create a one instance using BTP cockpit ui. Let us call it test_blog and I have assigned one role once create this is how it looks likeCopy the json file and put it in the folder and file name is instance-api.jsonJson{
“grant-types”: [
“client_credentials”
],
“redirect-uris”: [],
“roles”: [
“AuthGroup_IntegrationDeveloper”
],
“token-validity”: 43200
}Now we will use json as parameter file for creating a new instance.cf create-service it-rt api odata-api -c instance-api.json
cf create-service-key odata-api key-01 Create instance for plan integration-flowRepeat the same step here as well to get the json file.json file{
“grant-types”: [
“client_credentials”
],
“redirect-uris”: [],
“roles”: [
“ESBMessaging.send”
],
“token-validity”: 3600
} Iflow
cf create-service it-rt integration-flow iflow_blog -c instance-integration-flow.json
cf create-service-key iflow_blog key-01 You can view the instance and key. https://help.sap.com/docs/integration-suite/sap-integration-suite/specifying-service-instance-and-service-key-parameters-in-json-formatAPIM plan apiportal-apiaccessJson{
“role”: “APIPortal.Administrator”
} cf create-service apimanagement-apiportal-trial apiportal-apiaccess apim_odata -c instance-api-access.json
cf create-service-key apim_odata key-01https://help.sap.com/docs/integration-suite/sap-integration-suite/api-access-plan-for-api-portalPlease be aware sometimes btp trial is giving error when creating this instance be it from cockpit or from terminal. I had a issue and posted here and after sometime it starts working again. https://community.sap.com/t5/technology-q-a/instance-creation-for-apiportal-apiaccess-plan-in-btp-trial-fails/qaq-p/14088211View KeysOnce you are done with creating keys you can run this command to view the keys.cf service-key odata-api key-01ConclusionOnce you are done with settting up the commands, next time trial account is deleleted, you can make use of the commands instead of creating them from btp cockpit.    Read More Technology Blog Posts by Members articles 

#SAP

#SAPTechnologyblog

You May Also Like

More From Author