azure-powershell icon indicating copy to clipboard operation
azure-powershell copied to clipboard

Set-AzureRmSqlServerThreatDetectionPolicy with a storage in different subscription

Open alex-3sr opened this issue 8 years ago • 5 comments

Description

Hi,

I notice that with Set-AzureRmSqlServerThreatDetectionPolicy we can't use a storage account located in a different subscription. Altought, it's possible with Set-AzureRmSqlServerAuditing where there are a StorageAccountSubscriptionId arguments. It's really missing

Script/Steps for Reproduction

Just try to setup SQL threat detection with Set-AzureRmSqlServerThreatDetectionPolicy by using a storage account in a different subscription.

Set-AzureRmSqlServerThreatDetectionPolicy -ResourceGroupName $RG -ServerName $sql -EmailAdmins $false -RetentionInDays "90" -StorageAccountName storageinothersub

Module Version

Get-Module -Name AzureRM -ListAvailable
ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     6.4.0      AzureRM
Script     6.0.1      AzureRM
Script     5.7.0      AzureRM
Script     5.4.1      AzureRM
Script     5.1.1      AzureRM

Environment Data

$PSVersionTable
Name                           Value
----                           -----
PSVersion                      5.1.17134.165
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.17134.165
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Debug Output

Set-AzureRmSqlServerThreatDetectionPolicy : Cannot find a storage account with the name 'storageinothersub'. It either does not exist, associated with a different subscription or you do not have the appropriate credentials to access
it.
At line:1 char:1
+ Set-AzureRmSqlServerThreatDetectionPolicy -ResourceGroupName $RG ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [Set-AzureRmSqlS...DetectionPolicy], Exception
    + FullyQualifiedErrorId : Microsoft.Azure.Commands.Sql.ThreatDetection.Cmdlet.SetAzureSqlServerThreatDetection

alex-3sr avatar Aug 02 '18 14:08 alex-3sr

@alex-3sr You might want to consider removing some older versions of the modules from yoru box - it looks like you have 5 versiosn simultaneously installed.

I think the real solution here is to use a resource id for the storage account - would this work for your scenario?

markcowl avatar Aug 02 '18 23:08 markcowl

@markcowl , yes using ResourceId is clearly enough For my point of view, using same arguments from Set-AzureRmSqlServerAuditing is better, cause we usually set theses 2 settings at same time, and so it could be more clear. But BTW, if it do the job, it's ok for me ;) Thanks

Ps : Yes, i need clean up some older version :)

alex-3sr avatar Aug 03 '18 07:08 alex-3sr

@jaredmoo Can you take alook?

markcowl avatar Aug 14 '18 21:08 markcowl

@ayeletshpigelman Can you take a look at this?

ghost avatar Jun 12 '19 21:06 ghost

It is by design since the user doesn't supply the storage key. We allow enabling ADS policy without storage account using Enable-AzSqlServerAdvancedDataSecurity command. Moreover, I will add an option to run Set-AzureRmSqlServerThreatDetectionPolicy without storage account since it is supported in the backend.

ayeletshpigelman avatar Jun 16 '19 12:06 ayeletshpigelman