Cloud : Microsoft Azure

Iverique
4 min readMay 24, 2024

--

Source: https://www.techthatworks.net/wp-content/uploads/2024/01/azure.png
  1. App Registration in Azure
  2. Azure CLI on Windows
  3. Create a user using Terraform
  4. Azure CLI on Linux

App Registration to Access Azure

App registration needs

  • Azure Active Directory
  • Tenant
  • Admin permissions to register
Azure default directory

Note: Azure Active Directory is now Microsoft Entra ID

Go to App Registrations

Azure Directory App Registrations
Register an application
New application

Roles and Permissions

API permissions

Install Azure CLI on Windows

Run powershell as Administrator

$ProgressPreference = 'SilentlyContinue'; Invoke-WebRequest -Uri https://aka.ms/installazurecliwindows -OutFile .\AzureCLI.msi; Start-Process msiexec.exe -Wait -ArgumentList '/I AzureCLI.msi /quiet'; Remove-Item .\AzureCLI.msi
Installing Azure CLI

Trying to Login using CLI

Azure CLI login
az login Error

Login to a tenant

az login --tenant TENANT_ID
“No subscriptions found for …” error

We should create a subscription

Azure subscription

After subscription is created

Azure login

Let’s try to create a new user using Terraform

Add this to main.tf

provider "azurerm" {
features {}
}

# Create an Azure AD user
resource "azuread_user" "example_user" {
user_principal_name = "admin@azure.iverique.com"
display_name = "Example User"
mail_nickname = "exampleuser"
password = "P@ssw0rd1234"
}

Run terraform

terraform init
terraform plan
terraform apply

We are having this error:

Create user error

Solution: Go to Custom domain names and add your domain name

AD custom domain names
Add custom domain name: azure.iverique.com
Adding TXT record to DNS
Custom domain name verified

We created a user successfully.

New user created
New user created

You can read more about adding the custom name solution here:

Install Azure CLI on Linux (Ubuntu)

sudo apt install azure-cli
Installing Azure CLI using APT

To unistall Azure CLI

sudo apt remove azure-cli
sudo apt autoremove

Login to Azure as Service Principal

az login --service-principal -u <app-id> -p <password-or-cert> --tenant <tenant>
Login to Azure as Service Principal

Login to Azure Container Registry

 sudo az acr login --name myregistry
Login to Azure Container Registry

Pull docker image from Azure Container Registry

You cannot pull this without being logged in.

sudo docker pull  my-registry.azurecr.io/repository:tag

--

--

Responses (1)