Azure / Community-Policy

This repo is for Microsoft Azure customers and Microsoft teams to collaborate in making custom policies.
MIT License
636 stars 327 forks source link

Add a support for auditing Azure SQL databases which aren't enabled the active geo-replications #249

Closed vienleidl closed 1 year ago

vienleidl commented 1 year ago

There should be an Azure Policy for auditing the active geo-replications which are not enabled on Azure SQL databases.

SebastianClaesson commented 1 year ago

Hi @vienleidl ,

I've added a policy and made a pull request to the repository. It might not be 100% perfect but hopefully it will assist you in the progress of displaying these resources. I believe perhaps that a resource graph query on a dashboard might be more helpful for you thought :)

PR: https://github.com/Azure/Community-Policy/pull/259

techlake commented 1 year ago

Closed as completed.

vienleidl commented 1 year ago

Hi @vienleidl ,

I've added a policy and made a pull request to the repository. It might not be 100% perfect but hopefully it will assist you in the progress of displaying these resources. I believe perhaps that a resource graph query on a dashboard might be more helpful for you thought :)

PR: #259

Thanks @SebastianClaesson! I found the replicationLinks property here. However, I'm not sure if it works. But I think it's really promised and hope that Azure Policy will support that 'field' property/alias (replicationLinks) soon.

If the database has been configured the geo-replica, we have the response as below:

{
  "value": [
    {
      "properties": {
        "partnerServer": "NAME_OF_REPLICA_SERVER",
        "partnerDatabase": "NAME_OF_REPLICA_DATABASE",
        "partnerLocation": "North Europe",
        "role": "Primary",
        "partnerRole": "Secondary",
        "replicationMode": "ASYNC",
        "startTime": "2018-01-03T09:02:54.723Z",
        "percentComplete": 100,
        "replicationState": "CATCH_UP",
        "isTerminationAllowed": true,
        "linkType": "GEO"
      },
      "id": "/subscriptions/SUBSCRIPTION_ID/resourceGroups/RESOURCE_GROUP_NAME/providers/Microsoft.Sql/servers/NAME_OF_REPLICA_SERVER/databases/NAME_OF_REPLICA_DATABASE/replicationLinks/XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
      "name": "XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
    }
  ]
}

If not enabled yet, the value is empty:

{
  "value": []
}