### Overview

The Azure Configuration View offers a unified setup interface for integrating Azure cost data with the platform. It begins with entering key credentials like configuration name, tenant ID, client ID, and client secret to securely connect with Azure services. The Connection Details section enables authentication and fetches available cost export settings from the selected subscription.

In the Cloud Cost Visibility section, users define export-related parameters such as export name, storage account connection string, container, and directory path—ensuring accurate access to Azure billing data. This end-to-end configuration allows automated, secure, and efficient cost visibility directly within the Cavisson platform.

### Prerequisites

- (Tenant ID): Azure Active Directory Tenant ID associated with your Azure account.
- Application Client ID: Client ID of the application registered in Azure AD.
- Client Secret: Secret key generated for the registered application in Azure AD.
- Default Subscription: Azure subscription from which billing data will be fetched.
- Export Name: Name of the cost export configuration in Azure Cost Management + Billing.
- Storage Account Connection: Connection string of the storage account where cost data is stored.
- Storage Container: Blob container where exported CSV files are placed.
- Storage Directory: Folder path inside the container where exported cost files are delivered.

### Azure Configuration

1. Name: Enter a unique name to identify this Azure configuration within the system.
2. Connection Details: Provide authentication information to establish a connection with Azure.
   - Directory Details (Tenant ID): Enter the Azure AD Tenant ID.
     To retrieve: Azure Portal → Home → Microsoft Entra ID → Overview Page → Copy Tenant ID
   - Application Client ID: Client ID from App registrations.
     To retrieve: Azure Portal → Microsoft Entra ID → Overview Page → Manage → App Registrations → select the application → overview → Copy Application (Client) Id
   - Client Secret: Secret generated for the registered application.
     To create: Azure portal → Microsoft Entra ID → Overview Page → Manage → App Registrations → select the application → manage → Certificates & secrets → new client secret → Add Description and expiry → Copy the value
   - Default Subscription: Select the subscription for billing data retrieval.
   - Load Subscription: Click to verify credentials and load cost export data.

### Cloud Cost Visibility Configuration

Configure how Azure will export cost and usage data into a specific storage account. By providing export name and storage details, the system fetches granular billing metrics used for cost optimization and reporting.

1. Export Name: To retrieve the Export Name, go to the Azure Portal and navigate to Cost Management + Billing. Under Cost Management, select the appropriate Subscription scope. Open the Exports section, choose the required export configuration, and copy the Export name. This name is required to identify and access the configured cost export.
2. Storage Account Connection:To retrieve the Storage Account Connection string, go to the Storage accounts section in the Azure Portal and select the account used for your cost export. In the side panel, scroll to Security + Networking and click on Access keys. Under the “key1” section, you’ll find a Connection string, copy this string and use it in the configuration. This enables secure access to your Azure Storage Account where billing data is stored.
3. Storage Container: The Storage Container is a Blob container within your storage account where Azure places the exported CSV files. To get this, navigate to your chosen Storage Account, then go to Data Storage > Containers. Here, you’ll find a list of all containers. Identify and select the one used in your cost export configuration. You can also verify the container name by going back to Cost Management + Billing > Exports, selecting your export, and checking the destination container details.
4. Storage Directory: The Storage Directory is the specific folder path inside the Blob container where Azure stores the exported cost data files. To locate it, go to Cost Management + Billing, Under Cost Management, select the appropriate Subscription scope. Open the Exports section, choose the required export configuration, and copy the Directory Name field this value needs to be entered exactly as it appears to ensure cost files are retrieved from the correct path inside the container

### Ensuring Updated Azure Cost Reports in Storage Directory

To maintain up-to-date cloud cost visibility, ensure that Azure exports billing data as CSV files to the correct storage container and directory using the steps below:

1. Step 1: Create an Azure Storage Account (if not existing)
   Home → Storage accounts → + Create → Fill required fields → Review + Create → Create
2. Step 2: Create a Blob Container
   Storage accounts → Select → Data Storage → Containers → + Container → Name & Create
3. Step 3: Navigate to Cost Management → Exports
   Home → Cost Management + Billing → Settings → Exports → + Create
   Set Export Type → Cost and usage (amortized)
4. Step 4: Configure Export Destination
   Provide Prefix (e.g., Cavisson) → Choose Subscription, Storage Account, Container & Directory → Create

Test and Save: Validates the configuration and saves it upon success.

Reset: Clears all fields and reloads the configuration form to default state.

Before connecting, ensure that Subscription ID, Directory (tenant) ID, Application (client) ID, and a Secret are available. If they are not, go to the Collect the required data section before proceeding to Connect to Cavisson.

### Collect the required data

1. Generate and copy Application (client) ID:
   - Azure portal → Microsoft Entra ID → App registrations.
   - Click + New registration, provide a name (e.g. Cavisson), and click Register at the bottom of the page.
   - The newly created Application (client) ID is available in the table under the Owned applications tab.
   - Copy the Application (client) ID and store it in a safe place.
2. Grant permissions:
   - Azure Home page → Subscriptions → select the ones you have provisioned to be linked to Cavisson.
   - Click Access control (IAM) in the left navigation bar → Role assignments tab → click +Add → Add role assignment.
   - Go to the Roles tab → Fill in the field:

     Selected role → Reader

   - Go to the Members tab → Fill in the fields:

     Assign access to → User, group, or service principal

     Members → Select the name of a registered application from the previous steps (e.g., Cavisson).
3. Save to add the role assignment.
4. Copy Directory (tenant) ID. Go to Home → App registrations → find registration name (e.g. Cavisson) → Overview → copy Directory (tenant) ID.
5. Create and copy Secret. Go to Home → Microsoft Entra ID -> Overview Page -> Manage -> App Registrations -> select the application -> manage -> Certificates & secrets -> new client secret -> Add Description and expiry .

### For Kubernetes data: Enable "Cost Analysis"

If the Enable Cost Analysis option is missing from your Azure Portal menu, it is almost always due to one of these three reasons.

1. Your Cluster is on the "Free" Tier (Most Likely).

   The "Cost Analysis" feature only works on the Standard or Premium tier. It is not available on the Free tier. If you are on the Free tier, the option will simply not appear or be grayed out.

   How to check and fix:
   - Go to your AKS Cluster in the portal.
   - Look at the Overview page.
   - Check the Tier or SKU field.
   - If it says Free, you must upgrade it to Standard to get the `k8s_pod` data.

   Note: Standard tier may incur a cost for the Uptime SLA (approx. $73/month depending on region), so ensure you want to pay this before switching.

2. You are looking in the wrong place.

   Azure moves menus frequently. If your tier is correct, try finding it here:

   - Search for Cost Management + Billing in the top search bar.
   - Click Cost analysis in the left menu.
   - Use the Scope picker to select your specific AKS cluster.
   - Look for a banner at the top asking you to Enable AKS Cost Analysis.
3. Force Enable it via Command Line (Best Method).

   Since the button is missing, the best way to "force" it on (or find out exactly why it's failing) is to use the Cloud Shell.

   - Click the Cloud Shell icon (>_) at the top right of the portal.
   - Run this exact command (replace names with your own):
   `az aks update --resource-group <YourResourceGroup> --name <YourClusterName> --enable-cost-analysis`
   Read the error:
   - If it succeeds: You are done! Wait 24 hours.
   - If it fails: The red error message will tell you the exact reason (e.g., "Operation not allowed on Free tier" or "Managed Identity missing").