Azure / azure-powershell

Microsoft Azure PowerShell
Other
4.21k stars 3.81k forks source link

Unable to use Get-AzureRMDiagnosticSetting or Set-AzureRMDiagnosticSetting #7873

Open rupanter opened 5 years ago

rupanter commented 5 years ago

Description

I am trying to run the cmdlets : Get-AzureRMDiagnosticSetting and Set-AzureRMDiagnosticSetting but both are failing with this :

WARNING: 9:15:49 PM - The namespace for all the model classes will change from Microsoft.Azure.Management.Monitor.Management.Models to Microsoft.Azure.Management.Monitor.Models in future rele ases. WARNING: 9:15:49 PM - The namespace for output classes will be uniform for all classes in future releases to make it independent of modifications in the model classes.

Script/Steps for Reproduction

Get-AzureRMDiagnosticSetting -ResourceID Set-AzureRMDiagnosticSetting -ResourceID

Module Version

PS C:\WINDOWS\system32> Get-Module AzureRm

ModuleType Version    Name                                ExportedCommands                                                                                                                        
---------- -------    ----                                ----------------                                                                                                                        
Script     6.12.0     AzureRM                                                                                                                                                                     
Script     6.8.1      AzureRM                                                                                                                                                                     

PS C:\WINDOWS\system32> Get-Module AzureRm.Insights

ModuleType Version    Name                                ExportedCommands                                                                                                                        
---------- -------    ----                                ----------------                                                                                                                        
Script     5.1.5      AzureRM.Insights                    {Add-AzureRmAutoscaleSetting, Add-AzureRmLogProfile, Add-AzureRmMetricAlertRule, Add-AzureRmWebtestAlertRule...}                        
Script     5.1.3      AzureRM.Insights                    {Add-AzureRmAutoscaleSetting, Add-AzureRmLogProfile, Add-AzureRmMetricAlertRule, Add-AzureRmWebtestAlertRule...}                        

Environment Data

Name                           Value                                                                                                                                                              
----                           -----                                                                                                                                                              
PSVersion                      5.1.17134.407                                                                                                                                                      
PSEdition                      Desktop                                                                                                                                                            
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                                                                                            
BuildVersion                   10.0.17134.407                                                                                                                                                     
CLRVersion                     4.0.30319.42000                                                                                                                                                    
WSManStackVersion              3.0                                                                                                                                                                
PSRemotingProtocolVersion      2.3                                                                                                                                                                
SerializationVersion           1.1.0.1 

Debug Output

cormacpayne commented 5 years ago

@rupanter both of the messages that you pasted are warnings and should not fail the build. Would you mind setting $DebugPreference = "Continue" and running the commands that are failing for you?

rupanter commented 5 years ago

For Get-AzureRMDiagnosticsetting we only get a warning, the cmdlet returns nothing. Is that expected behaviour?

For Set-AzureRMDiagnosticsetting, this is the error : Set-AzureRmDiagnosticSetting -ResourceId "/subscriptions/0ef3b69c0578/resourceGroups/Basictesting/providers/Microsoft.Network/applicationGateways/Rupanter" -Enabled $true

As per documents this should work

Set-AzureRmDiagnosticSetting : Exception type: ErrorResponseException, Message: At least one data sink needs to be specified., Code: BadRequest, Status code:BadRequest, Reason phrase: Bad Request At line:1 char:1

DEBUG INFORMATION : DEBUG: 10:08:59 PM - SetAzureRmDiagnosticSettingCommand begin processing with ParameterSet 'OldSetDiagnosticSetting'. DEBUG: 10:08:59 PM - using account id 'ruchh@microsoft.com'... WARNING: 10:08:59 PM - The namespace for all the model classes will change from Microsoft.Azure.Management.Monitor.Management.Models to Microsoft.Azure.Management.Monitor.Models in future rel eases. WARNING: 10:08:59 PM - The namespace for output classes will be uniform for all classes in future releases to make it independent of modifications in the model classes. WARNING: 10:08:59 PM - The arguments Categories and Timegrains now have aliases Category and Timegrain respectively. The plural names will be removed in future releases. DEBUG: 10:08:59 PM - Processing using command line arguments DEBUG: 10:08:59 PM - Listing existing diagnostics settings for resourceId '/subscriptions/f28f2c24-b393-4dda-b471-0ef3b69c0578/resourceGroups/Basictesting/providers/Microsoft.Network/applicationG ateways/Rupanter' DEBUG: [Common.Authentication]: Authenticating using Account: 'ruchh@microsoft.com', environment: 'AzureCloud', tenant: '72f988bf-86f1-41af-91ab-2d7cd011db47' DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : DEBUG: 11/22/2018 16:38:59: b1c7e46b-87f3-4a69-84c6-8f4454d7e3c6 - AcquireTokenHandlerBase: === Token Acquisition started: Authority: https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/ Resource: https://management.core.windows.net/ ClientId: 1950a258-227b-4e31-a9cf-717495945fc2 CacheType: Microsoft.Azure.Commands.Common.Authentication.ProtectedFileTokenCache (4 items) Authentication Target: User

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : DEBUG: 11/22/2018 16:38:59: - TokenCache: Deserialized 4 items to token cache.

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 : DEBUG: 11/22/2018 16:38:59: b1c7e46b-87f3-4a69-84c6-8f4454d7e3c6 - TokenCache: Looking up cache for a token...

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : DEBUG: 11/22/2018 16:38:59: b1c7e46b-87f3-4a69-84c6-8f4454d7e3c6 - TokenCache: An item matching the requested resource was found in the cache

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 : DEBUG: 11/22/2018 16:38:59: b1c7e46b-87f3-4a69-84c6-8f4454d7e3c6 - TokenCache: 54.6919775333333 minutes left until token in cache expires

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : DEBUG: 11/22/2018 16:38:59: b1c7e46b-87f3-4a69-84c6-8f4454d7e3c6 - TokenCache: A matching item (access token or refresh token or both) was found in the cache

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : DEBUG: 11/22/2018 16:38:59: b1c7e46b-87f3-4a69-84c6-8f4454d7e3c6 - AcquireTokenHandlerBase: === Token Acquisition finished successfully. An access token was retuned: Access Token Hash: Rv3SRcAESCcmioUOFlBAMR9bBKE9Qr6l9zyQMoPwdM0= Refresh Token Hash: DljZiXgF2BgyZZsHjQXu74iMN+kIcimEJe78r9cQVUs= Expiration Time: 11/22/2018 17:33:40 +00:00 User Hash: Syw1JIQpkKYQgB2P+ASWnDzmUEKLBU5n1xPnkXTJYrg=

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : DEBUG: 11/22/2018 16:38:59: 1aa93b35-e6bb-4786-bdb9-ee7d911d3a82 - AcquireTokenHandlerBase: === Token Acquisition started: Authority: https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/ Resource: https://management.core.windows.net/ ClientId: 1950a258-227b-4e31-a9cf-717495945fc2 CacheType: Microsoft.Azure.Commands.Common.Authentication.ProtectedFileTokenCache (4 items) Authentication Target: User

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : DEBUG: 11/22/2018 16:38:59: - TokenCache: Deserialized 4 items to token cache.

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 : DEBUG: 11/22/2018 16:38:59: 1aa93b35-e6bb-4786-bdb9-ee7d911d3a82 - TokenCache: Looking up cache for a token...

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : DEBUG: 11/22/2018 16:38:59: 1aa93b35-e6bb-4786-bdb9-ee7d911d3a82 - TokenCache: An item matching the requested resource was found in the cache

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 : DEBUG: 11/22/2018 16:38:59: 1aa93b35-e6bb-4786-bdb9-ee7d911d3a82 - TokenCache: 54.6918902566667 minutes left until token in cache expires

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : DEBUG: 11/22/2018 16:38:59: 1aa93b35-e6bb-4786-bdb9-ee7d911d3a82 - TokenCache: A matching item (access token or refresh token or both) was found in the cache

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : DEBUG: 11/22/2018 16:38:59: 1aa93b35-e6bb-4786-bdb9-ee7d911d3a82 - AcquireTokenHandlerBase: === Token Acquisition finished successfully. An access token was retuned: Access Token Hash: Rv3SRcAESCcmioUOFlBAMR9bBKE9Qr6l9zyQMoPwdM0= Refresh Token Hash: DljZiXgF2BgyZZsHjQXu74iMN+kIcimEJe78r9cQVUs= Expiration Time: 11/22/2018 17:33:40 +00:00 User Hash: Syw1JIQpkKYQgB2P+ASWnDzmUEKLBU5n1xPnkXTJYrg=

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

HTTP Method: GET

Absolute Uri: https://management.azure.com//subscriptions/f28f2c24-b393-4dda-b471-0ef3b69c0578/resourceGroups/Basictesting/providers/Microsoft.Network/applicationGateways/Rupanter/providers/microsoft.insights/ diagnosticSettings?api-version=2017-05-01-preview

Headers: x-ms-client-request-id : 99707555-827d-41ea-a965-872a34716c7c accept-language : en-US

Body:

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

Status Code: OK

Headers: Pragma : no-cache Strict-Transport-Security : max-age=31536000; includeSubDomains x-ms-request-id : 073890f0-8f6c-4b1a-ac69-a7878896f2b9 x-ms-ratelimit-remaining-subscription-reads: 11994 x-ms-correlation-request-id : 4c7f14e1-1c44-4bfe-a66e-3e51a4c9e746 x-ms-routing-request-id : SOUTHINDIA:20181122T163900Z:4c7f14e1-1c44-4bfe-a66e-3e51a4c9e746 X-Content-Type-Options : nosniff Cache-Control : no-cache Date : Thu, 22 Nov 2018 16:39:00 GMT Server : Microsoft-IIS/10.0

Body: { "value": [] }

DEBUG: 10:09:02 PM - Diagnostic setting named: 'service' not found in list of 0 settings. Creating a new one. DEBUG: 10:09:02 PM - Retrieving supported categories for resource: '/subscriptions/f28f2c24-b393-4dda-b471-0ef3b69c0578/resourceGroups/Basictesting/providers/Microsoft.Network/applicationGateways /Rupanter' DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : DEBUG: 11/22/2018 16:39:02: e98e678b-cf1b-4ea5-8f88-817c8e884234 - AcquireTokenHandlerBase: === Token Acquisition started: Authority: https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/ Resource: https://management.core.windows.net/ ClientId: 1950a258-227b-4e31-a9cf-717495945fc2 CacheType: Microsoft.Azure.Commands.Common.Authentication.ProtectedFileTokenCache (4 items) Authentication Target: User

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : DEBUG: 11/22/2018 16:39:02: - TokenCache: Deserialized 4 items to token cache.

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 : DEBUG: 11/22/2018 16:39:02: e98e678b-cf1b-4ea5-8f88-817c8e884234 - TokenCache: Looking up cache for a token...

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : DEBUG: 11/22/2018 16:39:02: e98e678b-cf1b-4ea5-8f88-817c8e884234 - TokenCache: An item matching the requested resource was found in the cache

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 : DEBUG: 11/22/2018 16:39:02: e98e678b-cf1b-4ea5-8f88-817c8e884234 - TokenCache: 54.63790336 minutes left until token in cache expires

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : DEBUG: 11/22/2018 16:39:02: e98e678b-cf1b-4ea5-8f88-817c8e884234 - TokenCache: A matching item (access token or refresh token or both) was found in the cache

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : DEBUG: 11/22/2018 16:39:02: e98e678b-cf1b-4ea5-8f88-817c8e884234 - AcquireTokenHandlerBase: === Token Acquisition finished successfully. An access token was retuned: Access Token Hash: Rv3SRcAESCcmioUOFlBAMR9bBKE9Qr6l9zyQMoPwdM0= Refresh Token Hash: DljZiXgF2BgyZZsHjQXu74iMN+kIcimEJe78r9cQVUs= Expiration Time: 11/22/2018 17:33:40 +00:00 User Hash: Syw1JIQpkKYQgB2P+ASWnDzmUEKLBU5n1xPnkXTJYrg=

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

HTTP Method: GET

Absolute Uri: https://management.azure.com//subscriptions/f28f2c24-b393-4dda-b471-0ef3b69c0578/resourceGroups/Basictesting/providers/Microsoft.Network/applicationGateways/Rupanter/providers/microsoft.insights/ diagnosticSettingsCategories?api-version=2017-05-01-preview

Headers: x-ms-client-request-id : cff29c83-53c3-4504-ad28-c89818c1a710 accept-language : en-US

Body:

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

Status Code: OK

Headers: Pragma : no-cache Strict-Transport-Security : max-age=31536000; includeSubDomains x-ms-request-id : 37cd5b6c-5396-4500-85c1-6c8aa0a646d2 x-ms-ratelimit-remaining-subscription-reads: 11993 x-ms-correlation-request-id : 0bd40cf3-7dc7-4f2b-9ff5-c9fceb64701e x-ms-routing-request-id : SOUTHINDIA:20181122T163901Z:0bd40cf3-7dc7-4f2b-9ff5-c9fceb64701e X-Content-Type-Options : nosniff Cache-Control : no-cache Date : Thu, 22 Nov 2018 16:39:00 GMT Server : Microsoft-IIS/10.0

Body: { "value": [ { "id": "/subscriptions/f28f2c24-b393-4dda-b471-0ef3b69c0578/resourcegroups/basictesting/providers/microsoft.network/applicationgateways/rupanter/providers/microsoft.insights/diagnosticSettin gsCategories/ApplicationGatewayAccessLog", "type": "microsoft.insights/diagnosticSettingsCategories", "name": "ApplicationGatewayAccessLog", "location": null, "kind": null, "tags": null, "properties": { "categoryType": "Logs" }, "identity": null }, { "id": "/subscriptions/f28f2c24-b393-4dda-b471-0ef3b69c0578/resourcegroups/basictesting/providers/microsoft.network/applicationgateways/rupanter/providers/microsoft.insights/diagnosticSettin gsCategories/ApplicationGatewayPerformanceLog", "type": "microsoft.insights/diagnosticSettingsCategories", "name": "ApplicationGatewayPerformanceLog", "location": null, "kind": null, "tags": null, "properties": { "categoryType": "Logs" }, "identity": null }, { "id": "/subscriptions/f28f2c24-b393-4dda-b471-0ef3b69c0578/resourcegroups/basictesting/providers/microsoft.network/applicationgateways/rupanter/providers/microsoft.insights/diagnosticSettin gsCategories/ApplicationGatewayFirewallLog", "type": "microsoft.insights/diagnosticSettingsCategories", "name": "ApplicationGatewayFirewallLog", "location": null, "kind": null, "tags": null, "properties": { "categoryType": "Logs" }, "identity": null }, { "id": "/subscriptions/f28f2c24-b393-4dda-b471-0ef3b69c0578/resourcegroups/basictesting/providers/microsoft.network/applicationgateways/rupanter/providers/microsoft.insights/diagnosticSettin gsCategories/AllMetrics", "type": "microsoft.insights/diagnosticSettingsCategories", "name": "AllMetrics", "location": null, "kind": null, "tags": null, "properties": { "categoryType": "Metrics" }, "identity": null } ] }

DEBUG: 10:09:03 PM - Setting supported categories for resource: '/subscriptions/f28f2c24-b393-4dda-b471-0ef3b69c0578/resourceGroups/Basictesting/providers/Microsoft.Network/applicationGateways/Ru panter' DEBUG: 10:09:03 PM - Merging data. Existing setting is: not null DEBUG: 10:09:03 PM - Changing the enable properties DEBUG: 10:09:03 PM - Setting Enabled property for logs DEBUG: 10:09:03 PM - Setting Enabled property for metrics DEBUG: 10:09:03 PM - Copying diagnostic settings DEBUG: 10:09:03 PM - Sending create/update request setting: service DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : DEBUG: 11/22/2018 16:39:03: 50ae267a-c1e7-43d4-9f85-6bc66c82d59a - AcquireTokenHandlerBase: === Token Acquisition started: Authority: https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/ Resource: https://management.core.windows.net/ ClientId: 1950a258-227b-4e31-a9cf-717495945fc2 CacheType: Microsoft.Azure.Commands.Common.Authentication.ProtectedFileTokenCache (4 items) Authentication Target: User

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : DEBUG: 11/22/2018 16:39:03: - TokenCache: Deserialized 4 items to token cache.

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 : DEBUG: 11/22/2018 16:39:03: 50ae267a-c1e7-43d4-9f85-6bc66c82d59a - TokenCache: Looking up cache for a token...

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : DEBUG: 11/22/2018 16:39:03: 50ae267a-c1e7-43d4-9f85-6bc66c82d59a - TokenCache: An item matching the requested resource was found in the cache

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 : DEBUG: 11/22/2018 16:39:03: 50ae267a-c1e7-43d4-9f85-6bc66c82d59a - TokenCache: 54.6274173366667 minutes left until token in cache expires

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : DEBUG: 11/22/2018 16:39:03: 50ae267a-c1e7-43d4-9f85-6bc66c82d59a - TokenCache: A matching item (access token or refresh token or both) was found in the cache

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : DEBUG: 11/22/2018 16:39:03: 50ae267a-c1e7-43d4-9f85-6bc66c82d59a - AcquireTokenHandlerBase: === Token Acquisition finished successfully. An access token was retuned: Access Token Hash: Rv3SRcAESCcmioUOFlBAMR9bBKE9Qr6l9zyQMoPwdM0= Refresh Token Hash: DljZiXgF2BgyZZsHjQXu74iMN+kIcimEJe78r9cQVUs= Expiration Time: 11/22/2018 17:33:40 +00:00 User Hash: Syw1JIQpkKYQgB2P+ASWnDzmUEKLBU5n1xPnkXTJYrg=

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

HTTP Method: PUT

Absolute Uri: https://management.azure.com//subscriptions/f28f2c24-b393-4dda-b471-0ef3b69c0578/resourceGroups/Basictesting/providers/Microsoft.Network/applicationGateways/Rupanter/providers/microsoft.insights/ diagnosticSettings/service?api-version=2017-05-01-preview

Headers: x-ms-client-request-id : 6d6a99f9-c3f5-424f-b830-580ef89e47e0 accept-language : en-US

Body: { "properties": { "metrics": [ { "category": "AllMetrics", "enabled": true } ], "logs": [ { "category": "ApplicationGatewayAccessLog", "enabled": true }, { "category": "ApplicationGatewayPerformanceLog", "enabled": true }, { "category": "ApplicationGatewayFirewallLog", "enabled": true } ] } }

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

Status Code: BadRequest

Headers: Pragma : no-cache Strict-Transport-Security : max-age=31536000; includeSubDomains x-ms-request-id : 00000000-0000-0000-0000-000000000000 x-ms-ratelimit-remaining-subscription-resource-requests: 149 x-ms-correlation-request-id : ded30fdc-520c-485c-980d-c6602d00e249 x-ms-routing-request-id : SOUTHINDIA:20181122T163903Z:ded30fdc-520c-485c-980d-c6602d00e249 X-Content-Type-Options : nosniff Cache-Control : no-cache Date : Thu, 22 Nov 2018 16:39:02 GMT Server : Microsoft-IIS/10.0

Body: { "code": "BadRequest", "message": "At least one data sink needs to be specified." }

Set-AzureRmDiagnosticSetting : Exception type: ErrorResponseException, Message: At least one data sink needs to be specified., Code: BadRequest, Status code:BadRequest, Reason phrase: Bad Request At line:1 char:1

DEBUG: AzureQoSEvent: CommandName - Set-AzureRmDiagnosticSetting; IsSuccess - False; Duration - 00:00:06.1432133; Exception - System.Management.Automation.PSInvalidOperationException: Exception t ype: ErrorResponseException, Message: At least one data sink needs to be specified., Code: BadRequest, Status code:BadRequest, Reason phrase: Bad Request ---> Microsoft.Azure.Management.Monitor.M odels.ErrorResponseException: Operation returned an invalid status code 'BadRequest' at Microsoft.Azure.Management.Monitor.DiagnosticSettingsOperations.d6.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.Azure.Management.Monitor.DiagnosticSettingsOperationsExtensions.d3.MoveNext() --- End of inner exception stack trace --- at Microsoft.Azure.Commands.Insights.MonitorCmdletBase.ExecuteCmdlet() at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord(); DEBUG: Finish sending metric. DEBUG: 10:09:06 PM - SetAzureRmDiagnosticSettingCommand end processing. DEBUG: 10:09:06 PM - SetAzureRmDiagnosticSettingCommand end processing.

maddieclayton commented 5 years ago

@gucalder Can you take a look at this issue?

almmechanics commented 5 years ago

I'm also experiencing the same issue with the az equivalent command

set-AzDiagnosticSetting : Exception type: ErrorResponseException, Message: At least one data sink needs to be specified., Code: BadRequest, Status code:BadRequest, Reason phrase: Bad Request
At line:1 char:1
+ set-AzDiagnosticSetting -ResourceId /subscriptions/9fe9cbe8-503f-42ab ...    
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~          
+ CategoryInfo          : CloseError: (:) [Set-AzDiagnosticSetting], PSInvalidOperationException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.Insights.Diagnostics.SetAzureRmDiagnosticSettingCommand
curious-toast commented 5 years ago

Get-AzDiagnosticSetting returns WARNING: 12:37:37 PM - The namespace for all the model classes will change from Microsoft.Azure.Management.Monitor.Management.Models to Microsoft.Azure.Management.Monitor.Models in future releases. WARNING: 12:37:37 PM - The namespace for output classes will be uniform for all classes in future releases to make it independent of modifications in the model classes.

maximeGendre commented 5 years ago

I had the same issue with Set-AzureRmDiagnosticSetting command

Message: At least one data sink needs to be specified

It works when I add "WorkspaceId" Property $Workspace = Get-AzureRmOperationalInsightsWorkspace -ResourceGroupName $RG -Name CDLDataFactory Set-AzureRmDiagnosticSetting -ResourceId ($factory.DataFactoryId) -Enabled $True -WorkspaceId ($Workspace.ResourceId) -Name DiagName

israelcr commented 5 years ago

Use Version 6.13.1 for AzureRM

https://www.powershellgallery.com/packages/AzureRM/6.13.1

Install-Module -Name AzureRM -RequiredVersion 6.13.1

Set-AzureRmDiagnosticSetting -Name "service" -ResourceId "/subscriptions/mysubscription/resourceGroups/myRG/providers/Microsoft.StreamAnalytics/streamingjobs/myStreamAn16May" -StorageAccountId "/subscriptions/mysubscription/resourceGroups/myRG/providers/Microsoft.Storage/storageAccounts/mystorage" -Enabled $true -RetentionEnabled $true -RetentionInDays 90

Get-AzureRmDiagnosticSetting -ResourceId "/subscriptions/mysubscription/resourceGroups/MyRG/providers/Microsoft.StreamAnalytics/streamingjobs/myStream"

bwarren18 commented 5 years ago

I'm getting the same WARNING messages, and no output, when using AzureRM 6.13.1 and Az 2.4.0.

Get-AzDiagnosticSetting -ResourceId $vm.id Get-AzureRmDiagnosticSetting -ResourceId $vm.id

WARNING: 10:37:22 AM - *** The namespace for all the model classes will change from Microsoft.Azure.Management.Monitor.Management.Models to Microsoft.Azure.Management.Monitor.Models in future releases.

WARNING: 10:37:22 AM - *** The namespace for output classes will be uniform for all classes in future releases to make it independent of modifications in the model classes.

nkiest commented 4 years ago

A destination is required, which is what the message is saying. Please specify a workspace, storage account, or eventhub. Also, AzureRM is deprecated, and you should use Az. If you are seeing an issue with set-AzDiagnosticSetting, and specifying a destination, please report back with your error.

nkiest commented 4 years ago

@bwarren18, Get-AzDiagnosticSetting does not work on VMs. It works on the resources listed here: https://docs.microsoft.com/en-us/azure/azure-monitor/platform/diagnostic-logs-schema

amarzavery commented 4 years ago

@nkiest - The source of truth is the swagger specification. .net sdk is generated from the spec and powershell commands use the generated .net sdk to make the request.

No where in the swagger spec, it is mentioned that workspaceId is a required property in the request body for the PUT operation.

This is a bug in the spec and any attempt made by a customer using the generated SDK or CLI/powershell command is doomed for failure unless they come across this github issue and provide the workspaceId.

asheniam commented 4 years ago

@amarzavery - Can you share example that you are running into where it says workspaceId is required property?

amarzavery commented 4 years ago

@asheniam - Commandlet returns with an error message

Message: At least one data sink needs to be specified..

This message goes away when workspaceId is provided. This proves that inorder for the command to execute successfully workspaceId is a required parameter.

asheniam commented 4 years ago

WorkspaceId is not required property. Customer can route diagnostic logs to storage account. Here is an example that I just verified on my subscription.

Set-AzDiagnosticSetting -ResourceId /subscriptions/{subscriptionId}/resourceGroups/LogicAppTest2RG/providers/Microsoft.Logic/workflows/LogicAppPass -Name setting3 -Enabled $true -StorageAccountId /subscriptions/{subscriptionId}/resourceGroups/andystorage0503/providers/Microsoft.Storage/storageAccounts/andystorage0503