public static DiagnosticSettingsData GetBasicDiagnosticSettingsData()
        {
            var data = new DiagnosticSettingsData()
            {
                StorageAccountId = "/subscriptions/db1ab6f0-4769-4b27-930e-01e2ef9c123c/resourcegroups/lockformonitor/providers/Microsoft.Storage/storageAccounts/testaccountforlog2",
                //ServiceBusRuleId = "/subscriptions/db1ab6f0-4769-4b27-930e-01e2ef9c123c/resourceGroups/testservicebusRG-9432/providers/Microsoft.ServiceBus/namespaces/testnamespacemgmt7892/AuthorizationRules/testfordiagnostic",
                //EventHubAuthorizationRuleId = "/subscriptions/db1ab6f0-4769-4b27-930e-01e2ef9c123c/resourceGroups/Default-EventHub-1375/providers/Microsoft.EventHub/namespaces/sdk-eventhub-Namespace-8280/eventhubs/testfordiagnosticsetting/authorizationRules/testfordiagonst",
                //EventHubName = "myeventhub",
                //WorkspaceId = "/subscriptions/db1ab6f0-4769-4b27-930e-01e2ef9c123c/resourcegroups/default-eventhub-1375/providers/microsoft.operationalinsights/workspaces/myworkspace",
                LogAnalyticsDestinationType = "Dedicated",
                Metrics =
                {
                    new MetricSettings(true)
                    {
                        Category        = "WorkflowMetrics",
                        RetentionPolicy = new RetentionPolicy(false, 0),
                    }
                },
                Logs =
                {
                    new LogSettings(true)
                    {
                        Category        = "Alert",
                        RetentionPolicy = new RetentionPolicy(false, 0)
                    }
                }
            };

            //var data = new DiagnosticSettingsData(ResourceIdentifier.Root, "mysetting", "Microsoft.Insights/diagnosticSettings", "/subscriptions/db1ab6f0-4769-4b27-930e-01e2ef9c123c/resourceGroups/teststorageRG-5335/providers/Microsoft.Storage/storageAccounts/teststoragemgmt8010", "/subscriptions/db1ab6f0-4769-4b27-930e-01e2ef9c123c/resourceGroups/testservicebusRG-9432/providers/Microsoft.ServiceBus/namespaces/testnamespacemgmt7892", "/subscriptions/db1ab6f0-4769-4b27-930e-01e2ef9c123c/resourcegroups/default-eventhub-1375/providers/microsoft.eventhub/namespaces/testnamespacemgmt1412", "myeventhub", metricSettings, logSettings, "/subscriptions/db1ab6f0-4769-4b27-930e-01e2ef9c123c", "Dedicated");
            return(data);
        }
Esempio n. 2
0
    private async Async.Task <OneFuzzResult <DiagnosticSettingsResource> > SetupAutoScaleDiagnostics(string autoScaleResourceUri, string autoScaleResourceName, string logAnalyticsWorkspaceId)
    {
        var logSettings = new LogSettings(true)
        {
            Category = "allLogs", RetentionPolicy = new RetentionPolicy(true, 30)
        };

        try {
            var parameters = new DiagnosticSettingsData {
                WorkspaceId = logAnalyticsWorkspaceId
            };
            parameters.Logs.Add(logSettings);
            var diagnostics = await _context.Creds.GetResourceGroupResource().GetDiagnosticSettings().CreateOrUpdateAsync(WaitUntil.Completed, $"{autoScaleResourceName}-diagnostics", parameters);

            if (diagnostics != null && diagnostics.HasValue)
            {
                return(OneFuzzResult.Ok(diagnostics.Value));
            }
            return(OneFuzzResult <DiagnosticSettingsResource> .Error(
                       ErrorCode.UNABLE_TO_CREATE,
                       $"The resulting diagnostics settings resource was null when attempting to create for {autoScaleResourceUri}"
                       ));
        } catch (Exception ex) {
            _logTracer.Exception(ex);
            return(OneFuzzResult <DiagnosticSettingsResource> .Error(
                       ErrorCode.UNABLE_TO_CREATE,
                       $"unable to setup diagnostics for auto-scale resource: {autoScaleResourceUri}"
                       ));
        }
    }
Esempio n. 3
0
        internal static DiagnosticSettingsResourceCollection DeserializeDiagnosticSettingsResourceCollection(JsonElement element)
        {
            Optional <IReadOnlyList <DiagnosticSettingsData> > value = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("value"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <DiagnosticSettingsData> array = new List <DiagnosticSettingsData>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(DiagnosticSettingsData.DeserializeDiagnosticSettingsData(item));
                    }
                    value = array;
                    continue;
                }
            }
            return(new DiagnosticSettingsResourceCollection(Optional.ToList(value)));
        }
 public static void AssertDiagnosticSetting(DiagnosticSettingsData data1, DiagnosticSettingsData data2)
 {
     //AssertTrackedResource(data1, data2);
     Assert.AreEqual(data1.Id, data2.Id);
     Assert.AreEqual(data1.Name, data2.Name);
 }