> ## Documentation Index
> Fetch the complete documentation index at: https://cloudanix.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Azure audit securitycenter security contacts not set remediation

### Triage and Remediation

<Tabs>
  <Tab title="Remediation">
    ### Remediation

    <AccordionGroup>
      <Accordion title="Using Console" defaultOpen="true">
        To remediate the "No Security Contact Set" misconfiguration in Azure, you can follow these steps:

        1. Log in to the Azure portal ([https://portal.azure.com](https://portal.azure.com)).
        2. Navigate to the Security Center by clicking on the "Security Center" icon in the left-hand menu.
        3. In the Security Center, click on the "Secure score" tab in the left-hand menu.
        4. Scroll down to the "No security contact set" item in the list and click on it.
        5. Click on the "Remediate" button to the right of the item.
        6. In the "Remediation tasks" pane that appears, select the subscription(s) and resource group(s) that you want to apply the remediation to.
        7. Click on the "Remediate" button at the bottom of the pane to apply the remediation.

        After completing these steps, Azure will set a security contact for the selected subscription(s) and resource group(s), which will ensure that security alerts and notifications are sent to the appropriate parties.

        #
      </Accordion>

      <Accordion title="Using CLI">
        To remediate the "No Security Contact Set" misconfiguration in Azure using Azure CLI, you can follow these steps:

        1. Open the Azure CLI and login to your Azure account.

        2. Run the following command to get the list of security contacts set for your subscription:

           ```
           az security contact list --query '[].{name:name,email:email}' --output table
           ```

           If the output is empty, it means that no security contact has been set for your subscription.

        3. To set a security contact for your subscription, run the following command:

           ```
           az security contact create --email <email_address> --name <name> --phone <phone_number>
           ```

           Replace `<email_address>`, `<name>`, and `<phone_number>` with the appropriate values.

        4. Once the command is executed successfully, run the following command again to verify that the security contact has been set:

           ```
           az security contact list --query '[].{name:name,email:email}' --output table
           ```

           The output should now show the security contact that you just set.

        By following these steps, you have successfully remediated the "No Security Contact Set" misconfiguration in Azure using Azure CLI.
      </Accordion>

      <Accordion title="Using Python">
        To remediate the misconfiguration "No Security Contact Set" in Azure using Python, you can follow these steps:

        1. Import the necessary modules:

        ```python theme={null}
        from azure.identity import DefaultAzureCredential
        from azure.mgmt.security import SecurityCenter
        ```

        2. Authenticate to Azure using the `DefaultAzureCredential`:

        ```python theme={null}
        credential = DefaultAzureCredential()
        ```

        3. Create a `SecurityCenter` client object:

        ```python theme={null}
        security_center_client = SecurityCenter(
            credential=credential,
            subscription_id="<subscription-id>"
        )
        ```

        Note: Replace `<subscription-id>` with your Azure subscription ID.

        4. Get the security contact for the subscription:

        ```python theme={null}
        security_contact = security_center_client.security_contacts.get(
            resource_group_name="<resource-group-name>",
            security_contact_name="<security-contact-name>"
        )
        ```

        Note: Replace `<resource-group-name>` and `<security-contact-name>` with the appropriate values.

        5. If the `security_contact` object is `None`, create a new security contact:

        ```python theme={null}
        if security_contact is None:
            security_center_client.security_contacts.create(
                resource_group_name="<resource-group-name>",
                security_contact_name="<security-contact-name>",
                email="<email-address>",
                phone="<phone-number>"
            )
        ```

        Note: Replace `<email-address>` and `<phone-number>` with the appropriate values.

        6. If the `security_contact` object is not `None`, update the existing security contact:

        ```python theme={null}
        else:
            security_center_client.security_contacts.create_or_update(
                resource_group_name="<resource-group-name>",
                security_contact_name="<security-contact-name>",
                email="<email-address>",
                phone="<phone-number>"
            )
        ```

        Note: Replace `<email-address>` and `<phone-number>` with the appropriate values.

        7. Verify that the security contact has been set:

        ```python theme={null}
        security_contact = security_center_client.security_contacts.get(
            resource_group_name="<resource-group-name>",
            security_contact_name="<security-contact-name>"
        )

        if security_contact is not None:
            print("Security contact set successfully.")
        else:
            print("Failed to set security contact.")
        ```

        That's it! These steps will remediate the misconfiguration "No Security Contact Set" in Azure using Python.
      </Accordion>

      <Accordion title="Using Terraform">
        ```hcl theme={null}
        resource "azurerm_security_center_contact" "security_contact" {
          # ID must be 'default' in current Azure Security Center API
          name = "default"

          email = "SECURITY_CONTACT_EMAIL@example.com" # replace with your security contact email
          phone = "+1-555-555-5555"                    # replace with your security contact phone (E.164 format)

          alert_notifications = true                   # enable email notifications for alerts
          alerts_to_admins    = "On"                   # send alerts to subscription admins as well
        }
        ```

        This adds the required Security Center contact; it does not force replacement of other resources, only creates/updates this contact object. After you add it, `terraform plan` should show this resource with `+ create` (or `~ update` if it already exists but differs).
      </Accordion>
    </AccordionGroup>
  </Tab>
</Tabs>
