|
| 1 | +--- |
| 2 | +applies_to: |
| 3 | + stack: all |
| 4 | + serverless: |
| 5 | + security: all |
| 6 | +--- |
| 7 | + |
| 8 | +# Set up Cloud Asset Discovery for Azure |
| 9 | + |
| 10 | +## Overview [cad-overview-azure] |
| 11 | + |
| 12 | +This page explains how to set up the Cloud Asset Discovery integration to inventory assets in Azure. |
| 13 | + |
| 14 | + |
| 15 | +## Requirements |
| 16 | + |
| 17 | +* The user who gives the Cloud Asset Discovery integration permissions in Azure must be an Azure subscription `admin`. |
| 18 | +* The Cloud Asset Discovery integration is available to all {{ecloud}} users. On-premise deployments require the [appropriate subscription](https://www.elastic.co/pricing) level. |
| 19 | +* The Cloud Asset Discovery integration is supported only on Azure, not on Azure Government. To request support, [open a GitHub issue](https://github.com/elastic/kibana/issues/new/choose). |
| 20 | + |
| 21 | + |
| 22 | + |
| 23 | +## Set up Cloud Asset Discovery for Azure [cad-setup-azure] |
| 24 | + |
| 25 | +You can set up Cloud Asset Discovery for Azure by enrolling an Azure organization (management group) containing multiple subscriptions, or by enrolling a single subscription. Either way, you will first add the Cloud Asset Discovery integration, then enable cloud account access. |
| 26 | + |
| 27 | +Two deployment technologies are available: agentless and agent-based. |
| 28 | + |
| 29 | +* [Agentless deployment](/solutions/security/cloud/asset-disc-azure.md#cad-azure-agentless) allows you to collect cloud posture data without having to manage the deployment of an agent in your cloud. |
| 30 | +* [Agent-based deployment](/solutions/security/cloud/asset-disc-azure.md#cad-azure-agent-based) requires you to deploy and manage an agent in the cloud account you want to monitor. |
| 31 | + |
| 32 | + |
| 33 | +## Agentless deployment [cad-azure-agentless] |
| 34 | + |
| 35 | +1. Find **Integrations** in the navigation menu or use the [global search field](/explore-analyze/find-and-organize/find-apps-and-objects.md). |
| 36 | +2. Search for and select `Cloud asset discovery`. |
| 37 | +3. Click **Add Cloud Asset Discovery**. |
| 38 | +4. Select **Azure**, then either **Azure Organization** to onboard your whole organization, or **Single Subscription** to onboard an individual subscription. |
| 39 | +5. Give your integration a name that matches the purpose or team of the Azure subscription/organization you want to monitor, for example, `dev-azure-account`. |
| 40 | +6. In **Deployment options**, select **Agentless**. |
| 41 | +7. Next, you’ll need to authenticate to Azure by providing a **Client ID**, **Tenant ID**, and **Client Secret**. To learn how to generate them, refer to [Service principal with client secret](/solutions/security/cloud/asset-disc-azure.md#cad-azure-client-secret). |
| 42 | +8. Once you’ve provided the necessary credentials, click **Save and continue** to finish deployment. Your data should start to appear within a few minutes. |
| 43 | + |
| 44 | +## Agent-based deployment [cad-azure-agent-based] |
| 45 | + |
| 46 | + |
| 47 | +### Add your Cloud Asset Discovery integration [cad-add-and-name-integration-azure] |
| 48 | + |
| 49 | +1. Find **Integrations** in the navigation menu or use the [global search field](/explore-analyze/find-and-organize/find-apps-and-objects.md). |
| 50 | +2. Search for and select `Cloud asset discovery`. |
| 51 | +3. Click **Add Cloud Asset Discovery**. |
| 52 | +4. In **Configure integration**, select **Azure**, then select either **Azure Organization** or **Single Subscription**, depending on which resources you want to monitor. |
| 53 | +5. Give your integration a name that matches the purpose or team of the Azure resources you want to monitor, for example, `azure-CAD-dev-1`. |
| 54 | + |
| 55 | + |
| 56 | +### Set up cloud account access [cad-set-up-cloud-access-section-azure] |
| 57 | + |
| 58 | +::::{note} |
| 59 | +To set up Cloud Asset Discovery for an Azure organization or subscription, you will need admin privileges for that organization or subscription. |
| 60 | +:::: |
| 61 | + |
| 62 | +For most users, the simplest option is to use an Azure Resource Manager (ARM) template to automatically provision the necessary resources and permissions in Azure. If you prefer a more hands-on approach or require a specific configuration not supported by the ARM template, you can use one of the manual setup options described next on this page. |
| 63 | + |
| 64 | + |
| 65 | +## ARM template setup (recommended) [cad-set-up-ARM] |
| 66 | + |
| 67 | +::::{note} |
| 68 | +If you are deploying to an Azure organization, you need the following permissions: `Microsoft.Resources/deployments/*`, `Microsoft.Authorization/roleAssignments/write`. You also need to [elevate access to manage all Azure subscriptions and management groups](https://learn.microsoft.com/en-us/azure/role-based-access-control/elevate-access-global-admin). |
| 69 | +:::: |
| 70 | + |
| 71 | + |
| 72 | +1. In **Setup Access**, select **ARM Template**. |
| 73 | +2. In **Where to add this integration**: |
| 74 | + |
| 75 | + 1. Select **New Hosts**. |
| 76 | + 2. Name the {{agent}} policy. Use a name that matches the resources you want to monitor. For example, `azure-dev-policy`. Click **Save and continue**. The **ARM Template deployment** window appears. |
| 77 | + 3. In a new tab, log in to the Azure portal, then return to {{kib}} and click **Launch ARM Template**. This will open the ARM template in Azure. |
| 78 | + 4. If you are deploying to an Azure organization, select the management group you want to monitor from the drop-down menu. Next, enter the subscription ID of the subscription where you want to deploy the VM that will scan your resources. |
| 79 | + 5. Copy the `Fleet URL` and `Enrollment Token` that appear in {{kib}} to the corresponding fields in the ARM Template, then click **Review + create**. |
| 80 | + 6. (Optional) Change the `Resource Group Name` parameter. Otherwise the name of the resource group defaults to a timestamp prefixed with `cloudbeat-`. |
| 81 | + |
| 82 | +3. Return to {{kib}} and wait for the confirmation of data received from your new integration. Then you can click **View Assets** to see your data. |
| 83 | + |
| 84 | + |
| 85 | +## Manual setup [cad-set-up-manual-azure] |
| 86 | + |
| 87 | +For manual setup, multiple authentication methods are available: |
| 88 | + |
| 89 | +* Managed identity (recommended) |
| 90 | +* Service principal with client secret |
| 91 | +* Service principal with client certificate |
| 92 | + |
| 93 | + |
| 94 | +### Option 1: Managed identity (recommended) [cad-azure-managed-identity-setup] |
| 95 | + |
| 96 | +This method involves creating an Azure VM (or using an existing one), giving it read access to the resources you want to monitor with Cloud Asset Discovery, and installing {{agent}} on it. |
| 97 | + |
| 98 | +1. Go to the Azure portal to [create a new Azure VM](https://portal.azure.com/#create/Microsoft.VirtualMachine-ARM). |
| 99 | +2. Follow the setup process, and make sure you enable **System assigned managed identity** in the **Management** tab. |
| 100 | +3. Go to your Azure subscription list and select the subscription or management group you want to monitor with Cloud Asset Discovery. |
| 101 | +4. Go to **Access control (IAM)**, and select **Add Role Assignment**. |
| 102 | +5. Select the `Reader` function role, assign access to **Managed Identity**, then select your VM. |
| 103 | + |
| 104 | +After assigning the role: |
| 105 | + |
| 106 | +1. Return to the **Add Cloud Asset Discovery** page in {{kib}}. |
| 107 | +2. In **Configure integration**, select **Azure**. In **Setup access**, select **Manual**. |
| 108 | +3. In **Where to add this integration**, select **New hosts**. |
| 109 | +4. Click **Save and continue**, then follow the instructions to install {{agent}} on your Azure VM. |
| 110 | + |
| 111 | +Wait for the confirmation that {{kib}} received data from your new integration. Then you can click **View Assets** to see your data. |
| 112 | + |
| 113 | + |
| 114 | +### Option 2: Service principal with client secret [cad-azure-client-secret] |
| 115 | + |
| 116 | +Before using this method, you must have set up a [Microsoft Entra application and service principal that can access resources](https://learn.microsoft.com/en-us/entra/identity-platform/howto-create-service-principal-portal#get-tenant-and-app-id-values-for-signing-in). |
| 117 | + |
| 118 | +1. On the **Add Cloud Asset Discovery integration** page, scroll to the **Setup access** section, then select **Manual**. |
| 119 | +2. For **Preferred manual method**, select **Service principal with Client Secret**. |
| 120 | +3. Go to the **Registered apps** section of [Microsoft Entra ID](https://ms.portal.azure.com/#view/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade/~/RegisteredApps). |
| 121 | +4. Click on **New Registration**, name your app and click **Register**. |
| 122 | +5. Copy your new app’s `Directory (tenant) ID` and `Application (client) ID`. Paste them into the corresponding fields in {{kib}}. |
| 123 | +6. Return to the Azure portal. Select **Certificates & secrets**, then go to the **Client secrets** tab. Click **New client secret**. |
| 124 | +7. Copy the new secret. Paste it into the corresponding field in {{kib}}. |
| 125 | +8. Return to Azure. Go to your Azure subscription list and select the subscription or management group you want to monitor with Cloud Asset Discovery. |
| 126 | +9. Go to **Access control (IAM)** and select **Add Role Assignment**. |
| 127 | +10. Select the `Reader` function role, assign access to **User, group, or service principal**, and select your new app. |
| 128 | +11. Return to the **Add Cloud Asset Discovery integration** page in {{kib}}. |
| 129 | +12. In **Where to add this integration**, select **New hosts**. |
| 130 | +13. Click **Save and continue**, then follow the instructions to install {{agent}} on your selected host. |
| 131 | + |
| 132 | +Wait for the confirmation that {{kib}} received data from your new integration. Then you can click **View Assets** to see your data. |
| 133 | + |
| 134 | + |
| 135 | +### Option 3: Service principal with client certificate [cad-azure-client-certificate] |
| 136 | + |
| 137 | +Before using this method, you must have set up a [Microsoft Entra application and service principal that can access resources](https://learn.microsoft.com/en-us/entra/identity-platform/howto-create-service-principal-portal#get-tenant-and-app-id-values-for-signing-in). |
| 138 | + |
| 139 | +1. From the **Add Cloud Asset Discovery integration** page, in **Setup access**, select **Manual**. |
| 140 | +2. For **Preferred manual method**, select **Service principal with client certificate**. |
| 141 | +3. Go to the **Registered apps** section of [Microsoft Entra ID](https://ms.portal.azure.com/#view/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade/~/RegisteredApps). |
| 142 | +4. Click on **New Registration**, name your app and click **Register**. |
| 143 | +5. Copy your new app’s `Directory (tenant) ID` and `Application (client) ID`. Paste them into the corresponding fields in {{kib}}. |
| 144 | +6. Return to Azure. Go to your Azure subscription list and select the subscription or management group you want to monitor with Cloud Asset Discovery. |
| 145 | +7. Go to **Access control (IAM)** and select **Add Role Assignment**. |
| 146 | +8. Select the `Reader` function role, assign access to **User, group, or service principal**, and select your new app. |
| 147 | + |
| 148 | +Next, create a certificate. If you intend to use a password-protected certificate, you must use a pkcs12 certificate. Otherwise, you must use a pem certificate. |
| 149 | + |
| 150 | +Create a pkcs12 certificate, for example: |
| 151 | + |
| 152 | +```shell |
| 153 | +# Create PEM file |
| 154 | +openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 -nodes |
| 155 | + |
| 156 | +# Create pkcs12 bundle using legacy flag (CLI will ask for export password) |
| 157 | +openssl pkcs12 -legacy -export -out bundle.p12 -inkey key.pem -in cert.pem |
| 158 | +``` |
| 159 | + |
| 160 | +Create a PEM certificate, for example: |
| 161 | + |
| 162 | +```shell |
| 163 | +# Generate certificate signing request (csr) and key |
| 164 | +openssl req -new -newkey rsa:4096 -nodes -keyout cert.key -out cert.csr |
| 165 | + |
| 166 | +# Generate PEM and self-sign with key |
| 167 | +openssl x509 -req -sha256 -days 365 -in cert.csr -signkey cert.key -out signed.pem |
| 168 | + |
| 169 | +# Create bundle |
| 170 | +cat cert.key > bundle.pem |
| 171 | +cat signed.pem >> bundle.pem |
| 172 | +``` |
| 173 | + |
| 174 | +After creating your certificate: |
| 175 | + |
| 176 | +1. Return to Azure. |
| 177 | +2. Navigate to the **Certificates & secrets** menu. Select the **Certificates** tab. |
| 178 | +3. Click **Upload certificate**. |
| 179 | + |
| 180 | + 1. If you’re using a PEM certificate that was created using the example commands above, upload `signed.pem`. |
| 181 | + 2. If you’re using a pkcs12 certificate that was created using the example commands above, upload `cert.pem`. |
| 182 | + |
| 183 | +4. Upload the certificate bundle to the VM where you will deploy {{agent}}. |
| 184 | + |
| 185 | + 1. If you’re using a PEM certificate that was created using the example commands above, upload `bundle.pem`. |
| 186 | + 2. If you’re using a pkcs12 certificate that was created using the example commands above, upload `bundle.p12`. |
| 187 | + |
| 188 | +5. Return to the **Add Cloud Asset Discovery** page in {{kib}}. |
| 189 | +6. For **Client Certificate Path**, enter the full path to the certificate that you uploaded to the host where you will install {{agent}}. |
| 190 | +7. If you used a pkcs12 certificate, enter its password for **Client Certificate Password**. |
| 191 | +8. For **Where to add this integration**, select **New hosts**. |
| 192 | +9. Click **Save and continue**, then follow the instructions to install {{agent}} on your selected host. |
| 193 | + |
| 194 | +Wait for the confirmation that {{kib}} received data from your new integration. Then you can click **View Assets** to see your data. |
0 commit comments