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

Set-AzureRmSqlDatabaseThreatDetectionPolicy throws an error saying "One or more of the email addresses you entered are not valid."

Open vinaydam opened this issue 8 years ago • 10 comments

Cmdlet(s)

Set-AzureRmSqlDatabaseThreatDetectionPolicy

PowerShell Version

5.1.16299.98

Module Version

5.1.1

OS Version

10.0.16299.98

Description

When we try to enable threat detection on a sql datawarehouse using the "Set-AzureRmSqlDatabaseThreatDetectionPolicy" cmdlet by specifying valid emails for the switch "NotificationEmailRecipients" separated by ';', it still throws an error saying "One or more of the email addresses you entered are not valid.". An observation is that this error is thrown if any character of the email address is in uppercase. And, when we convert all the email addresses to lower case, this works fine. I don't think the case of the email address should be a limitation here.

Debug Output

Set-AzureRmSqlDatabaseThreatDetectionPolicy -ServerName ktserver -DatabaseName testsdw -ResourceGroupName [ResourceGroupName] -StorageAccountName jzrkbgvlflt0un0evenmmadw -NotificationRecipientsEmails "[email protected]" -Debug
DEBUG: 8:01:30 PM - SetAzureSqlDatabaseThreatDetection begin processing with ParameterSet '__AllParameterSets'.
DEBUG: 8:01:33 PM - using account id '[UserId]'...
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : 
DEBUG: 02/05/2018 14:31:33: dbc3290a-0c85-429d-b035-f09844b8ad8b - AcquireTokenHandlerBase: === Token Acquisition started:
	Authority: https://login.microsoftonline.com/bd3eeefe-e2f5-40d6-abc6-bbb9c8f48d03/
	Resource: https://management.core.windows.net/
	ClientId: 1950a258-227b-4e31-a9cf-717495945fc2
	CacheType: Microsoft.Azure.Commands.Common.Authentication.AuthenticationStoreTokenCache (1 items)
	Authentication Target: User
	

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 : 
DEBUG: 02/05/2018 14:31:33: dbc3290a-0c85-429d-b035-f09844b8ad8b - TokenCache: Looking up cache for a token...

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : 
DEBUG: 02/05/2018 14:31:33: dbc3290a-0c85-429d-b035-f09844b8ad8b - TokenCache: An item matching the requested resource was found in the cache

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 : 
DEBUG: 02/05/2018 14:31:33: dbc3290a-0c85-429d-b035-f09844b8ad8b - TokenCache: An expired or near expiry token was found in the cache

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : 
DEBUG: 02/05/2018 14:31:33: dbc3290a-0c85-429d-b035-f09844b8ad8b - TokenCache: A matching item (access token or refresh token or both) was found in the ca
che

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 : 
DEBUG: 02/05/2018 14:31:33: dbc3290a-0c85-429d-b035-f09844b8ad8b - <RefreshAccessTokenAsync>d__11: Refreshing access token...

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 : 
DEBUG: 02/05/2018 14:31:33: dbc3290a-0c85-429d-b035-f09844b8ad8b - TokenCache: Storing token in the cache...

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 : 
DEBUG: 02/05/2018 14:31:33: dbc3290a-0c85-429d-b035-f09844b8ad8b - TokenCache: An item was stored in the cache

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : 
DEBUG: 02/05/2018 14:31:33: dbc3290a-0c85-429d-b035-f09844b8ad8b - AcquireTokenHandlerBase: === Token Acquisition finished successfully. An access token w
as retuned:
	Access Token Hash: U1TAFNuYFLvzuQd83pEx4I0DWNAGcug+w0fJX/4Zrb0=
	Refresh Token Hash: VMTF7YJCLgc7dDgF2k5KCEBhIwPlrDnWq3eiTmi4GHU=
	Expiration Time: 02/05/2018 15:31:32 +00:00
	User Hash: Mk9l/pRzYF4eQmXWbqXQaY/LIcv6KvisB6i/dFJg36U=
	

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : 
DEBUG: 02/05/2018 14:31:33:  - TokenCache: Serializing token cache with 1 items.

DEBUG: ============================ HTTP REQUEST ============================

HTTP Method:
GET

Absolute Uri:
https://management.azure.com/subscriptions/[SubscriptionId]/resourceGroups/[ResourceGroupName]/providers/Microsoft.Sql/server
s/ktserver?api-version=2015-05-01-preview

Headers:
x-ms-client-request-id        : f0731539-4e60-4622-842b-dfb49fdb6959
accept-language               : en-US

Body:



DEBUG: ============================ HTTP RESPONSE ============================

Status Code:
OK

Headers:
Pragma                        : no-cache
x-ms-request-id               : eeef2b08-31c7-4d2d-921e-3ace27f3914e
x-ms-ratelimit-remaining-subscription-reads: 14894
x-ms-correlation-request-id   : dbb7fbc6-fb41-4795-a761-bb304fc15e2b
x-ms-routing-request-id       : CENTRALINDIA:20180205T143134Z:dbb7fbc6-fb41-4795-a761-bb304fc15e2b
Strict-Transport-Security     : max-age=31536000; includeSubDomains
Cache-Control                 : no-cache
Date                          : Mon, 05 Feb 2018 14:31:34 GMT
Server                        : Microsoft-HTTPAPI/2.0

Body:
{
  "kind": "v12.0",
  "properties": {
    "administratorLogin": "test",
    "version": "12.0",
    "state": "Ready",
    "fullyQualifiedDomainName": "ktserver.database.windows.net"
  },
  "location": "westeurope",
  "id": "/subscriptions/[SubscriptionId]/resourceGroups/[ResourceGroupName]/providers/Microsoft.Sql/servers/ktserver",
  "name": "ktserver",
  "type": "Microsoft.Sql/servers"
}


DEBUG: [Common.Authentication]: Renewing Token with Type: 'Bearer', Expiry: '02/05/2018 13:20:47 +00:00', MultipleResource? 'True', Tenant: 'bd3eeefe-e2f5
-40d6-abc6-bbb9c8f48d03', UserId: '[UserId]'
DEBUG: [Common.Authentication]: User info for token DisplayId: '[UserId]', Name: Vinay Damisetty, IdProvider: 'https://sts.wi
ndows.net/bd3eeefe-e2f5-40d6-abc6-bbb9c8f48d03/', Uid: '2a4b3d72-419c-43b2-9560-8ec7aad95a1b'
DEBUG: [Common.Authentication]: Checking token expiration, token expires '02/05/2018 13:20:47 +00:00' Comparing to '02/05/2018 14:31:34 +00:00' With thres
hold '00:05:00', calculated time until token expiry: '-01:10:46.7005961'
DEBUG: [Common.Authentication]: Token is expired
DEBUG: [Common.Authentication]: Acquiring token using context with Authority 'https://login.microsoftonline.com/bd3eeefe-e2f5-40d6-abc6-bbb9c8f48d03/', Co
rrelationId: '00000000-0000-0000-0000-000000000000', ValidateAuthority: 'True'
DEBUG: [Common.Authentication]: Acquiring token using AdalConfiguration with Domain: 'bd3eeefe-e2f5-40d6-abc6-bbb9c8f48d03', AdEndpoint: 'https://login.mi
crosoftonline.com/', ClientId: '1950a258-227b-4e31-a9cf-717495945fc2', ClientRedirectUri: urn:ietf:wg:oauth:2.0:oob
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : 
DEBUG: 02/05/2018 14:31:34: ecd21322-283c-4428-b7d4-99f2a51404b1 - AcquireTokenHandlerBase: === Token Acquisition started:
	Authority: https://login.microsoftonline.com/bd3eeefe-e2f5-40d6-abc6-bbb9c8f48d03/
	Resource: https://management.core.windows.net/
	ClientId: 1950a258-227b-4e31-a9cf-717495945fc2
	CacheType: Microsoft.Azure.Commands.Common.Authentication.AuthenticationStoreTokenCache (1 items)
	Authentication Target: User
	

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 : 
DEBUG: 02/05/2018 14:31:34: ecd21322-283c-4428-b7d4-99f2a51404b1 - TokenCache: Looking up cache for a token...

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : 
DEBUG: 02/05/2018 14:31:34: ecd21322-283c-4428-b7d4-99f2a51404b1 - TokenCache: An item matching the requested resource was found in the cache

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 : 
DEBUG: 02/05/2018 14:31:34: ecd21322-283c-4428-b7d4-99f2a51404b1 - TokenCache: 59.9730939 minutes left until token in cache expires

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : 
DEBUG: 02/05/2018 14:31:34: ecd21322-283c-4428-b7d4-99f2a51404b1 - TokenCache: A matching item (access token or refresh token or both) was found in the ca
che

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : 
DEBUG: 02/05/2018 14:31:34: ecd21322-283c-4428-b7d4-99f2a51404b1 - AcquireTokenHandlerBase: === Token Acquisition finished successfully. An access token w
as retuned:
	Access Token Hash: U1TAFNuYFLvzuQd83pEx4I0DWNAGcug+w0fJX/4Zrb0=
	Refresh Token Hash: VMTF7YJCLgc7dDgF2k5KCEBhIwPlrDnWq3eiTmi4GHU=
	Expiration Time: 02/05/2018 15:31:32 +00:00
	User Hash: Mk9l/pRzYF4eQmXWbqXQaY/LIcv6KvisB6i/dFJg36U=
	

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : 
DEBUG: 02/05/2018 14:31:34:  - TokenCache: Serializing token cache with 1 items.

DEBUG: ============================ HTTP REQUEST ============================

HTTP Method:
GET

Absolute Uri:
https://management.azure.com/subscriptions/[SubscriptionId]/resourceGroups/[ResourceGroupName]/providers/Microsoft.Sql/server
s/ktserver/databases/testsdw/securityAlertPolicies/Default?api-version=2014-04-01

Headers:

Body:



DEBUG: ============================ HTTP RESPONSE ============================

Status Code:
OK

Headers:
x-ms-request-id               : 4010c96a-18ed-40ea-9e24-9db582e837a3
X-Content-Type-Options        : nosniff
DataServiceVersion            : 3.0;
Strict-Transport-Security     : max-age=31536000; includeSubDomains
x-ms-ratelimit-remaining-subscription-reads: 14892
x-ms-correlation-request-id   : 01af321b-1096-415c-81bb-6adb4fc6d5f7
x-ms-routing-request-id       : CENTRALINDIA:20180205T143135Z:01af321b-1096-415c-81bb-6adb4fc6d5f7
Cache-Control                 : no-store, no-cache
Date                          : Mon, 05 Feb 2018 14:31:34 GMT
Server                        : Microsoft-HTTPAPI/2.0

Body:
{
  "id": "/subscriptions/[SubscriptionId]/resourceGroups/[ResourceGroupName]/providers/Microsoft.Sql/servers/ktserver/database
s/testsdw/securityAlertPolicies/Default",
  "name": "Default",
  "type": "Microsoft.Sql/servers/databases/securityAlertPolicies",
  "location": "West Europe",
  "kind": null,
  "properties": {
    "useServerDefault": "Disabled",
    "state": "Enabled",
    "disabledAlerts": "Sql_Injection",
    "emailAddresses": "[email protected]",
    "emailAccountAdmins": "Enabled",
    "storageEndpoint": "",
    "storageAccountAccessKey": "",
    "retentionDays": 0
  }
}


Set-AzureRmSqlDatabaseThreatDetectionPolicy : One or more of the email addresses you entered are not valid.
At line:1 char:1
+ Set-AzureRmSqlDatabaseThreatDetectionPolicy -ServerName ktserver -Dat ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [Set-AzureRmSqlD...DetectionPolicy], Exception
    + FullyQualifiedErrorId : Microsoft.Azure.Commands.Sql.ThreatDetection.Cmdlet.SetAzureSqlDatabaseThreatDetection
 
DEBUG: AzureQoSEvent: CommandName - Set-AzureRmSqlDatabaseThreatDetectionPolicy; IsSuccess - False; Duration - 00:00:06.7863659; Exception - System.Except
ion: One or more of the email addresses you entered are not valid.
   at Microsoft.Azure.Commands.Sql.ThreatDetection.Model.BaseThreatDetectionPolicyModel.ValidateContent()
   at Microsoft.Azure.Commands.Sql.ThreatDetection.Cmdlet.SetAzureSqlDatabaseThreatDetection.ApplyUserInputToModel(DatabaseThreatDetectionPolicyModel mode
l)
   at Microsoft.Azure.Commands.Sql.Common.AzureSqlCmdletBase`2.ExecuteCmdlet()
   at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord();
DEBUG: Finish sending metric.
DEBUG: 8:01:40 PM - SetAzureSqlDatabaseThreatDetection end processing.
DEBUG: 8:01:40 PM - SetAzureSqlDatabaseThreatDetection end processing.

Script/Steps for Reproduction

  1. Create a SQL datawarehouse
  2. Create a storage account
  3. Enable threat detection on the datawarehouse by mentioning some notification email recipients using the above mentioned cmdlet.

vinaydam avatar Feb 05 '18 14:02 vinaydam

@jaredmoo Can you take a look?

markcowl avatar Feb 05 '18 17:02 markcowl

Is there any update on this?

vinaydam avatar Feb 09 '18 07:02 vinaydam

@jaredmoo ping

cormacpayne avatar Jul 10 '18 22:07 cormacpayne

I have informed the threat detection team, they will take a look. Cheers

jaredmoo avatar Jul 10 '18 23:07 jaredmoo

Looking into it.

tomerrt avatar Jul 12 '18 15:07 tomerrt

Hi, we have a bug. the mitigation is to set an email address which starts with a lower case. I have sent a pull request to fix this and the fix will be part of the new powershell release: https://github.com/Azure/azure-powershell/pull/6671

thanks, Ayelet

ayeletshpigelman avatar Jul 16 '18 13:07 ayeletshpigelman

@jaredmoo @ranisha2 Looks like the referenced PR above was closed and this was handled service side. Can you close if this was fixed?

markcowl avatar Aug 03 '19 01:08 markcowl

@ayeletshpigelman Can you please close if this was fixed?

ranisha2 avatar Aug 04 '19 08:08 ranisha2

I'll check if it is fixed. If not I'll fix this

ayeletshpigelman avatar Aug 05 '19 13:08 ayeletshpigelman

a PR with a fix: https://github.com/Azure/azure-powershell/pull/9890

ayeletshpigelman avatar Aug 22 '19 15:08 ayeletshpigelman