Skip to main content
All CollectionsAdding an account to Uniskai
Add an Azure account with a Single subscription using Automatic connection
Add an Azure account with a Single subscription using Automatic connection

Learn how to add an Azure account

Updated this week

Note: To add an Azure subscription, you need permission to create service clients and assign roles.

Step 1

Navigate to the ‘Account Manager’ tab.

If you don't have any accounts, your Account Manager menu will look like the picture below. Click on the 'Add new account' button.

If you already have some accounts, your Account Manager menu will appear as shown below. Click on the ‘Add environment’ button.

Step 2

Click on the ‘Azure (service principal)’ button.

Step 3

Select Single Subscription.

Step 4

4.1

You'll see the ‘Connect your Azure subscription’ page.

4.2

In the first field, Account Name, you can either enter a specific name or leave it as the default ‘Azure,’ but it should not exceed 32 characters.

4.3

Next, select the Access Type (the selected type will have a white point on a blue background):

  • Read-only: You can only view your resources and possible actions, without using the main functionality.

  • Read/write: You can use all the offered functions, such as converting to spot, scheduling resources, removing unused resources, and rightsizing your resources. For this manual, we use READ/WRITE mode.

4.4

Then, select the Connection (the selected connection will have a white point on a blue background):

  • Automation: A shell script will automatically create a JSON key file.

  • Manual: You will need to create a new Service Principal manually and provide connection metadata.

Now, choose the Automatic connection.

4.4.1

You can create a JSON file using the manual on the page. Click the ‘Read manual’ button in the ‘Azure project connection’ pop-up.

The manual will look like this:

4.4.2

Log in to Azure and open the Cloud Shell console.

Cloud Shell will look like this:

4.4.3

Note: When opening the shell for the first time, you'll be prompted to create a new storage account. You can create one automatically with a click on ‘Create storage’ or set the storage account and file share names using advanced settings.

After creating storage, you will see a Cloud Shell terminal that looks like this:

4.4.4

Import the setup automation module by executing this command (just paste the next code into the Cloud Shell terminal):

Invoke-Expression $([System.Text.Encoding]::UTF8.GetString($(Invoke-WebRequest -Uri `
"https://uniskai-eu-templates.s3.eu-central-1.amazonaws.com/azure/setup-uniskai-connection.ps1" `
-UseBasicParsing).Content))

Executed code will look like this:

4.4.5

Define the scope for connection. Find your subscription ID in the Management Groups, which lists all entities associated with your Azure account and includes the name and ID for each one.

$Scope = '/subscriptions/<YOUR_SUBSCRIPTION_ID>'

Step 5

Run the setup procedure. Use -Access ReadWrite for read/write access:

$Connection = Setup-UniskaiConnection `
-Access 'ReadWrite' `
-Scope $Scope `
-ApplicationName 'Uniskai' `
-PrincipalId ''
$Connection

Step 6

Configure Azure cost exports.

Setup-CostExports `
-Scope $Scope `
-PrincipalId $Connection.principal_id `
-StorageAccountId '' `
-StorageSubscriptionId $Connection.subscription_id `
-HistoryMonths 12

Step 7

Get the setup script's generated config file and upload it to Uniskai.

$configFile = "uniskai-connection.json"
$Connection | ConvertTo-Json | Out-File -FilePath $configFile

Write-Output "Connection configuration file created: $configFile"
Write-Output "Download this file and register it in Uniskai."
Write-Warning "If you are using Azure PowerShell, click on the Upload/Download files button at the toolbar,"
Write-Warning "enter the '$configFile' file name and click on Download."

Note: If you're using Azure Cloud Shell, click the Upload/Download files button on the toolbar, choose Download, enter the script's output file name, and click Download. Then click on the “Click here to download your file.” link that appears on the bottom right.

Troubleshooting

1. If you see $0 in Uniskai billing after refreshing the account, please check that you have access to view Azure costs in this subscription. If you don’t see any values in Cost analysis or your export files have all cost columns equal to 0, ask your admin to enable policy to view Azure charges.

2. Cost export creation might fail when you are not using Enterprise Agreement Subscriptions.

An error occurred: ERROR: (404) No EA Subscriptions for Management Group with managementGroupId: {name of managment group} were found ...

You can create cost exports manually via Azure Portal UI for the desired scope or each subscription separately.

Step 8

Go to the Uniskai page and upload the created JSON file:

Check all information and click the ‘Connect subscription’ button:

Step 9

The account was successfully connected; you can see the connected account on the Account Manager page:

Did this answer your question?