How do I use Cloud Foundry to login to IBM Bluemix? - ibm-cloud

I am trying to get started using IBM Bluemix and want to use the Cloud Foundry CLI to login and manage my applications. But I cannot figure out how to login using the cf command. I think what I am missing is the API endpoint I need to provide for the cf login command:
cf login -a [API_URL] -u [USERNAME] -p [PASSWORD]
I suspect I use my IBM ID username and password, but I'm not sure about the API_URL. Seems like this should be an easy question to search, but I have not been able to find an answer.

You set the api endpoint like this:
cf api https://api.ng.bluemix.net
and then you login with cf login.
Alternatively you can use the European endpoint:
cf api https://api.eu-gb.bluemix.net
EDIT:
Alternatively, as you were implying, you can pass the API endpoint to cf login directly via the -a option:
cf login -a https://api.ng.bluemix.net -u <ibm.com id>

Found the answer to my question. The API endpoint for IBM bluemix is https://api.ng.bluemix.net. That was the key piece of information I was missing to login to IBM Bluemix using the Cloud Foundry CLI:
cf login -a https://api.ng.bluemix.net -u <IBM ID Name> -p <IBM ID Password>
I'm impressed with how easy the rest of the cf command is to manage apps.

Related

IBM Cloud and Database for MongoDB

I'd like to know how to get the string connection of my MongoDB database to use with Mongoose, I was looking for and there are old info, and when I though I found a good documentation, well, it doesn't work(this is the link), the command doesn't exist, this is the comand [ ibmcloud cdb deployment-connections example-mongo -u admin
** ] specifically ***CDB*
I hope someone can help me please.
You can get the connection string to Databases for MongoDB using the ibmcloud cdb plugin but must be installed first. You can install it using the command:
ibmcloud plugin install cloud-databases
Then you can start using the cdb plugin. After that, you can get your MongoDB connection strings with:
ibmcloud cdb cxn <name of mongo deployment>
For the CA cert you'll need to connect, the plugin will decode it for you with:
ibmcloud cdb cacert <name of mongo deployment>
You'll also be able to change the admin password as well.
Or, you can go to your IBM Cloud dashboard, click on your Databases for MongoDB database, select "Service credentials" on the left panel of your MongoDB management panel, and then create some service credentials. This service credential will give you a username, password, the CA cert (encoded), and connection strings, as well.

Unable to create repository on IBM Cloud

I'm able to login successfully with : ibmcloud cr login
but when i try to create a repository in the registry, i have the following error :
docker push registry.eu-gb.bluemix.net/fdutreg/ksrepo
The push refers to repository [registry.eu-gb.bluemix.net/fdutreg/ksrepo]
428c97da766c: Preparing
unauthorized: The login credentials are not valid, or your IBM Cloud account is not active.
Any idea ?
Replace registry.eu-gb.bluemix.net by registry.eu-de.bluemix.net and now this is ok.
2 years later but probably someone could be experimenting the same issue. The thing is that you are not authenticate to the registry. You can authenticate with an API key using:
docker login -u iamapikey -p apikey registry_url
For the apikey field you can create an apikey in Manage > IAM > APIkeys > Create an IBM Cloud API key in ibm.cloud.com
It is important to know that Using --password via the CLI is insecure. Use --password-stdin. You can find alternatives in https://cloud.ibm.com/docs/Registry?topic=Registry-registry_access
Log your local Docker daemon into the IBM Cloud Container Registry.run the following command:
ibmcloud cr login

How to authenticate user accessing my finatra rest api (Scala) with azure active directory

I have a Scala rest service on Finatra and would like to authenticate users accessing my rest service using Azure Active Directory.
Currently, I can do a curl to get the access token:
curl -s -X POST https://login.microsoftonline.com/tenant id/oauth2/token -d grant_type=password -d username=$username -d password=$pass -d resource=$resID -d client_id=$id -d client_secret=$key
But it requires the user to pass his password as a parameter which is a security concern.
Is there a way to authenticate the user using Azure AD with taking in the password (I am pretty sure this is not possible) or asking him to sign in?
It is not recommended to use your user and password to login Azure account. You had better create service principal to sign in your Azure account. Please refer to this link: Use portal to create an Azure Active Directory application and service principal that can access resources.
Also, you could use Azure CLI 2.0 to create this.
az ad sp create-for-rbac --name {appId} --password "{strong password}"
Example:
az ad sp create-for-rbac --name shuiexample --password "Password012!!"
You could get result like below:
{
"appId": "bca24913-026d-4020-b9f1-add600bf9045",
"displayName": "shuiexample1234",
"name": "http://shuiexample1234",
"password": "*******",
"tenant": "*******"
}
Sign in using the service principal.
APPID="bca24913-026d-4020-b9f1-add600bf9045"
PASSWORD="******"
TENANTID="*******"
curl -X POST -H "Content-Type: application/x-www-form-urlencoded" -d 'client_id=$APPID&scope=https%3A%2F%2Fgraph.microsoft.com%2F.default&client_secret=$PASSWORD&grant_type=client_credentials' 'https://login.microsoftonline.com/$TENANTID/oauth2/token'

Unable to login to Bluemix via CLI

I am unable to login to my Bluemix account using CLI.
Here are the steps that I followed:
Connected to Bluemix from CLI
E:\myStuff\Coding\Node.js\CloudantDB-NodeApp>bluemix api https://api.ng.bluemix.net
Invoke 'cf api https://api.ng.bluemix.net'...
Setting api endpoint to https://api.ng.bluemix.net...
OK
API endpoint: https://api.ng.bluemix.net (API version: 2.44.0)
Not logged in. Use 'bluemix login' to log in.
Login to Bluemix
Here is the error that I am getting -
E:\myStuff\Coding\Node.js\CloudantDB-NodeApp>bluemix login -u arindam.chattopadhya#wipro.com -o BAS-CES-IBM INTEGRATION -s DEV
Invoke 'cf login -u arindam.chattopadhya#wipro.com -o BAS-CES-IBM INTEGRATION -s DEV'...
API endpoint: https://api.ng.bluemix.net
Password>
Authenticating...
OK
API endpoint: https://api.ng.bluemix.net (API version: 2.44.0)
User: arindam.chattopadhya#wipro.com
No org or space targeted, use 'cf target -o ORG -s SPACE'
FAILED
Error finding org BAS-CES-IBM
Organization BAS-CES-IBM not found
The following command works -
bluemix login -u arindam.chattopadhya#wipro.com -o 'BAS-CES-IBM INTEGRATION' -s DEV

bluemix cf reports "No orgs found"

I can see and operate organization in dashboard. But cannot find any org in cf command line.
C:\Users\zlf>cf login -u 3218789763#qq.com -o suisl -s dev
API endpoint: https://api.ng.bluemix.net
Password>
Authenticating...
OK
FAILED
Error finding org suisl
Organization suisl not found
API endpoint: https://api.ng.bluemix.net (API version: 2.40.0)
User: 3218789763#qq.com
No org or space targeted, use 'cf target -o ORG -s SPACE'
C:\Users\zlf>cf orgs
Getting orgs as 3218789763#qq.com...
name
No orgs found
http://imgur.com/a/rLKJi
If you are using US South Region:
use these commands:
cf api https://api.ng.bluemix.net
cf login -u bluemix_id -o myorg
If you are using United Kingdom region:
use these commands:
cf api https://api.eu-gb.bluemix.net
cf login -u bluemix_id -o myorg
for Sydney region
cf api https://api.au-syd.bluemix.net
cf login -u bluemix_id -o myorg
for Germany region
cf api https://api.eu-de.bluemix.net
cf login -u bluemix_id -o myorg
you can know which region, org and space is currently set typing:
cf target
If you are using the 'bluemix' plugin you can use the below command
example:
bx api <apiLink> and bx target
you have created the org in the Sydney Region but you are looking for the Org in the US region (https://api.ng.bluemix.net).
For Sydney please use the following API endpoint: api.au-syd.bluemix.net
To find the CF API endpoints for each region please refer to the docs.
Could you please change the region to your region and then target the org and space. You may target your region using below command:
ibmcloud target --cf-api 'https://api.REGION.cf.cloud.ibm.com' -r REGION -o
Change REGION with your region(eu-gb) for London use your ibm cloud email id for org.
Thanks,
This message was taken from Anamika Agawarl from Coursera.