Go to Azure Active Directory
Choose App Registrations
Click on New application registration
Choose the name for your app, application type and Sign-on URL. It doesn't matter which url you choose and you can always change it later
Here Application ID is your Service principal client ID
Click on Settings then keys and provide your key name and value. When you click one Save, remember take a good care of your key value. And you can choose when the key will be expired
You have following options for key duration.
This is your Service Principal Key
Now we have add Contributor role
Search for your subscription name in Azure Portal
Click on it and go to Access control(IAM)
Click on Add role assignment
Role should be Contributor, select your app we registered before and click on Save.