Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for enable ms-support auditing #18607

Closed
1 task done
MichalSino opened this issue Oct 3, 2022 · 19 comments · Fixed by #18609
Closed
1 task done

Support for enable ms-support auditing #18607

MichalSino opened this issue Oct 3, 2022 · 19 comments · Fixed by #18609
Labels
enhancement service/mssql Microsoft SQL Server
Milestone

Comments

@MichalSino
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Description

There is not possibility to set "Enable Auditing of Microsoft support operations" and "Use different audit log destinations" through azurerm provider. Is it possible to add this feature to azurerm_mssql_server_extended_auditing_policy or create new resource like above? After creating resource we could set destination in diagnostic_settings (like with extended auditing policy).

New or Affected Resource(s)/Data Source(s)

azurerm_mssql_server_mssupport_auditing_policy

Potential Terraform Configuration

resource "azurerm_mssql_server_mssupport_auditing_policy" "example" {
  server_id                       = azurerm_mssql_server.example.id
  enabled                         = true
  log_monitoring_enabled          = true
  storage_endpoint                = azurerm_storage_account.example.primary_blob_endpoint
  storage_account_subscription_id = azurerm_subscription.primary.subscription_id
  retention_in_days               = 6
}

resource "azurerm_monitor_diagnostic_setting" "example" {
  name                       = "example"
  target_resource_id         = "${azurerm_mssql_server.example.id}/databases/master"
  log_analytics_workspace_id = data.azurerm_log_analytics_workspace.example.id

  log {
    category = "DevOpsAuditing"
    enabled  = true

    retention_policy {
      enabled = false
    }
  }
}

References

No response

@aristosvo
Copy link
Contributor

I'll take a quick look!

@MichalSino
Copy link
Author

Thanks. I forgot to write that it is relates to Azure mssql server :)

@aristosvo
Copy link
Contributor

aristosvo commented Oct 3, 2022

@MichalSino If you know how to build the provider yourselves locally, feel free to check out the PR and get a feel if this is working for you!

The reason I'm proposing this is because I've the experience that the configuration of auditing on SQL might be a bit more complicated than it seems at first sight.

@MichalSino
Copy link
Author

MichalSino commented Oct 3, 2022

@aristosvo Thanks for quick reply. Unfortunately I've never written provider, so I don't know how to do it.

I've read this pull request and I think it is not full solution, because in cli we can use those 2 commands (and they do 2 different things, but similar):

This is what you mentioned:
az sql server audit-policy update -g ${data.azurerm_resource_group.rg.name} -n ${azurerm_mssql_server.server.name} --set isDevopsAuditEnabled=true --lats Enabled --lawr ${azurerm_log_analytics_workspace.law.id}

And this is what I found in docs:
az sql server ms-support audit-policy update --ids ${azurerm_mssql_server.server..id} --lats Enabled --lawri ${azurerm_log_analytics_workspace.law.id} --state Enabled

Someone from MS should write which one is correct. ;)

I can't find the difference in API, but second one works better in my case.

But thanks for reply. I will wait for this. :)

@aristosvo
Copy link
Contributor

@MichalSino Thanks for your pointers! Enhanced the resource to a separate one, which indeed uses different APIs and works better.

I'll run some tests and add some docs, let's get it going!

@MichalSino
Copy link
Author

@aristosvo great. I will wait for good news. :)

Thanks a lot.

@fcatacut
Copy link
Contributor

And this is what I found in docs: az sql server ms-support audit-policy update --ids azurermmssqlserver.server..id−−latsEnabled−−lawri{azurerm_log_analytics_workspace.law.id} --state Enabled

Regarding az sql server ms-support audit-policy update,

Auditing of Microsoft Support operations for your logical server allows you to audit Microsoft support engineers' operations when they need to access your server during a support request. The use of this capability, along with your auditing, enables more transparency into your workforce and allows for anomaly detection, trend visualization, and data loss prevention.

Source: Auditing of Microsoft Support operations (September 2022)

@MichalSino
Copy link
Author

I know what does it mean. :)

The question is which method is better to set up it and why. ;)

@fcatacut
Copy link
Contributor

In the image below, az sql server audit-policy update configures the "Azure SQL Auditing" section while az sql server ms-support audit-policy update configures the "Auditing of Microsoft support operations" section, which is the one that you want based on your original description.

image

@MichalSino
Copy link
Author

As I said earlier I know it. :)

But we can also set it up using

az sql server audit-policy update -g ${data.azurerm_resource_group.rg.name} -n ${azurerm_mssql_server.server.name} --set isDevopsAuditEnabled=true --lats Enabled --lawr ${azurerm_log_analytics_workspace.law.id}

@fcatacut
Copy link
Contributor

Looking at the az sql server audit-policy update documentation and unless I'm missing something, none of its parameters will configure the destination for MS support operation when "using different audit log destinations" is checked. This is what you're asking for, right? If so, the only way to configure these would be with az sql server ms-support audit-policy update.

image

@MichalSino
Copy link
Author

So, you suggest to use first one if we want to enable Ms support auditing and second one if we want to change the destination of those logs, right?

@fcatacut
Copy link
Contributor

To enable SQL auditing, you have to run az sql server audit-policy update --state Enabled specifying the audit logs destination.

If you want to enable the auditing of Microsoft support operations, I think that you have to run the following: az sql server ms-support audit-policy update -g mygroup -n myserver --state Enabled. If you want to send the audit logs to a different destination, you'd have to specify additional parameters.

@MichalSino
Copy link
Author

But what is isDevOpsauditEnabled=true for in
az sql server audit-policy update -g ${data.azurerm_resource_group.rg.name} -n ${azurerm_mssql_server.server.name} --set isDevopsAuditEnabled=true --lats Enabled --lawr

@fcatacut
Copy link
Contributor

Azure CLI parameters are formatted in lower case characters and words are delimited by dashes whereas the code snippet that you provided is in camel case. What is the source of your snippet?

Note: There is a "Devops operations Audit Logs" log category for Azure SQL Databases.

image

@fcatacut
Copy link
Contributor

There is a IsDevopsAuditEnabled property, but it's for the Azure SDK for .NET: https://learn.microsoft.com/en-us/dotnet/api/microsoft.azure.management.sql.models.serverblobauditingpolicy.isdevopsauditenabled.

@MichalSino
Copy link
Author

Azure CLI parameters are formatted in lower case characters and words are delimited by dashes whereas the code snippet that you provided is in camel case. What is the source of your snippet?

Note: There is a "Devops operations Audit Logs" log category for Azure SQL Databases.

image

When you do "az sql server audit-policy update --ids sql-server-resource-id" there is property "isDevopsAuditEnabled": false and I changed it to true to set this
image

But I understand that this should not be used to set ms-support auditing.

@github-actions github-actions bot added this to the v3.30.0 milestone Oct 31, 2022
@github-actions
Copy link

github-actions bot commented Nov 4, 2022

This functionality has been released in v3.30.0 of the Terraform Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@github-actions
Copy link

github-actions bot commented Dec 4, 2022

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement service/mssql Microsoft SQL Server
Projects
None yet
3 participants