> ## 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 email not set remediation

### Triage and Remediation

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

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

        1. Log in to the Azure portal ([https://portal.azure.com/](https://portal.azure.com/)).
        2. Click on the "Security Center" icon from the left-hand menu.
        3. In the Security Center, click on "Security policy" from the left-hand menu.
        4. Under the "Policy Management" section, click on the policy that is not compliant with the email set requirement.
        5. In the policy details, click on the "Edit" button.
        6. In the "Edit policy" window, scroll down to the "Notifications" section.
        7. Ensure that the "Send email notifications" toggle is set to "On".
        8. In the "Security contact email" field, enter the email address that should receive the security notifications.
        9. Click on the "Save" button to save the changes.
        10. Verify that the policy is now compliant by checking the "Compliance" status in the policy details.

        By following these steps, you have now remediated the misconfiguration of "No Security Contact Email Set" in Azure.

        #
      </Accordion>

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

        1. Open the Azure CLI on your local machine or in the Azure portal.

        2. Run the following command to set the security contact email:

        ```
        az security contact create --email <email_address> --name "Security Contact"
        ```

        Replace `<email_address>` with the email address you want to set as the security contact. You can also replace "Security Contact" with a different name for the contact.

        3. Verify that the email address has been set by running the following command:

        ```
        az security contact show
        ```

        This command will display the details of the security contact, including the email address.

        4. If you need to update the security contact email address in the future, you can use the following command:

        ```
        az security contact update --email <new_email_address> --name "Security Contact"
        ```

        Replace `<new_email_address>` with the new email address you want to use for the security contact.

        By following these steps, you can remediate the "No Security Contact Email Set" misconfiguration in Azure using Azure CLI.
      </Accordion>

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

        1. Import the necessary libraries:

        ```
        from azure.identity import DefaultAzureCredential
        from azure.mgmt.security import SecurityCenter
        from azure.mgmt.resource import ResourceManagementClient
        ```

        2. Authenticate with Azure using the `DefaultAzureCredential` class:

        ```
        credential = DefaultAzureCredential()
        ```

        3. Create a `SecurityCenter` client object:

        ```
        security_center_client = SecurityCenter(
            credential=credential,
            subscription_id="<your-subscription-id>"
        )
        ```

        4. Get the security contact email for the subscription:

        ```
        resource_client = ResourceManagementClient(
            credential=credential,
            subscription_id="<your-subscription-id>"
        )

        subscription = resource_client.subscriptions.get("<your-subscription-id>")
        security_contact_email = subscription.security_contact_email
        ```

        5. If the security contact email is not set, set it to a valid email address:

        ```
        if not security_contact_email:
            subscription.security_contact_email = "<your-email-address>"
            resource_client.subscriptions.create_or_update(
                subscription_id="<your-subscription-id>",
                parameters=subscription
            )
        ```

        6. Verify that the security contact email has been set:

        ```
        subscription = resource_client.subscriptions.get("<your-subscription-id>")
        security_contact_email = subscription.security_contact_email
        print(f"Security contact email: {security_contact_email}")
        ```

        Note: Replace `<your-subscription-id>` and `<your-email-address>` with your own values.

        By following the above steps, you can remediate the misconfiguration of "No Security Contact Email Set" in Azure using Python.
      </Accordion>

      <Accordion title="Using Terraform">
        ```hcl theme={null}
        resource "azurerm_security_center_contact" "security_contact" {
          # This is a subscription-level resource; it applies to the current provider subscription.

          alert_notifications = true
          alerts_to_admins    = "On" # or "Off" if you do not want admins to also receive alerts

          email = "SECURITY_CONTACT_EMAIL@example.com" # replace with your security contact email
          phone = "SECURITY_CONTACT_PHONE_NUMBER"      # optional but recommended, e.g. "+1-555-123-4567"
        }
        ```

        Changing or adding the `email` value updates the existing contact in place and does not force resource replacement.

        For verification, `terraform plan` should show an update (or creation, if it didn't exist) to `azurerm_security_center_contact.security_contact` with `email` set to your desired address and `alert_notifications`/`alerts_to_admins` as configured.
      </Accordion>
    </AccordionGroup>
  </Tab>
</Tabs>
