This is a scenario for creating a service principal in Microsoft Entra ID.
# Move to the scenario directory
cd infra/scenarios/create_service_principal
# Authenticate with Azure via Azure CLI
az login
# (Optional) Confirm the details for the currently logged-in user
az ad signed-in-user show
# Set environment variables
export ARM_SUBSCRIPTION_ID=$(az account show --query id --output tsv)
export TF_VAR_service_principal_name="baseline-environment-on-azure-terraform_tf"
export TF_VAR_github_environment="tf"
# Initialize the Terraform configuration.
terraform init
# Deploy the infrastructure
terraform apply -auto-approve
# Grant permissions to the application
application_object_id=$(terraform output -raw application_object_id)
az ad app permission admin-consent --id $application_object_id
# Destroy the infrastructure
terraform destroy -auto-approve
If you want to create a service principal using Azure CLI, you can refer to the create-service-principal.sh script.