예제 #1
0
 private static void AreEqual(ApplicationInsightsComponentExportRequest request, ApplicationInsightsComponentExportConfiguration response)
 {
     Assert.Equal(request.IsEnabled, response.IsUserEnabled, ignoreCase: true);
     Assert.Equal(request.RecordTypes, response.RecordTypes);
     Assert.Equal(request.DestinationStorageSubscriptionId, response.DestinationStorageSubscriptionId);
     Assert.Equal(request.DestinationStorageLocationId, response.DestinationStorageLocationId);
     Assert.Equal(request.DestinationAccountId, response.DestinationAccountId);
 }
예제 #2
0
        public override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();

            if (this.ApplicationInsightsComponent != null)
            {
                this.ResourceGroupName = this.ApplicationInsightsComponent.ResourceGroupName;
                this.Name = this.ApplicationInsightsComponent.Name;
            }

            if (!string.IsNullOrEmpty(this.ResourceId))
            {
                ResourceIdentifier identifier = new ResourceIdentifier(this.ResourceId);
                this.ResourceGroupName = identifier.ResourceGroupName;
                this.Name = identifier.ResourceName;
            }

            ApplicationInsightsComponentExportRequest exportRequest = new ApplicationInsightsComponentExportRequest();

            exportRequest.IsEnabled                        = "true";
            exportRequest.DestinationAccountId             = this.StorageAccountId;
            exportRequest.DestinationStorageSubscriptionId = ParseSubscriptionFromId(this.StorageAccountId);
            exportRequest.DestinationAddress               = this.StorageSASUri;
            exportRequest.DestinationStorageLocationId     = this.StorageLocation;
            exportRequest.DestinationType                  = "Blob";
            exportRequest.RecordTypes                      = string.Join(",", ConvertToRecordType(this.DocumentType));

            if (this.ShouldProcess(this.Name, "Create Application Insights Continuous Export"))
            {
                try
                {
                    var exportConfigurationsResponse = this.AppInsightsManagementClient
                                                       .ExportConfigurations
                                                       .CreateWithHttpMessagesAsync(
                        this.ResourceGroupName,
                        this.Name,
                        exportRequest)
                                                       .GetAwaiter()
                                                       .GetResult();

                    WriteComponentExportConfiguration(exportConfigurationsResponse.Body.FirstOrDefault());
                }
                catch (Microsoft.Rest.Azure.CloudException exception)
                {
                    if (exception.Response != null && exception.Response.StatusCode == System.Net.HttpStatusCode.Conflict)
                    {
                        throw new System.Exception("There is already an export defined for this destination.");
                    }

                    throw exception;
                }
            }
        }
        public override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();

            if (this.ApplicationInsightsComponent != null)
            {
                this.ResourceGroupName = this.ApplicationInsightsComponent.ResourceGroupName;
                this.Name = this.ApplicationInsightsComponent.Name;
            }

            if (!string.IsNullOrEmpty(this.ResourceId))
            {
                ResourceIdentifier identifier = new ResourceIdentifier(this.ResourceId);
                this.ResourceGroupName = identifier.ResourceGroupName;
                this.Name = identifier.ResourceName;
            }

            ApplicationInsightsComponentExportRequest exportRequest = new ApplicationInsightsComponentExportRequest();

            if (this.DisableConfiguration)
            {
                exportRequest.IsEnabled = "false";
            }
            else
            {
                exportRequest.IsEnabled = "true";
            }
            exportRequest.DestinationAccountId             = this.StorageAccountId;
            exportRequest.DestinationStorageSubscriptionId = ParseSubscriptionFromId(this.StorageAccountId);
            exportRequest.DestinationAddress           = this.StorageSASUri;
            exportRequest.DestinationStorageLocationId = this.StorageLocation;
            exportRequest.DestinationType = "Blob";
            exportRequest.RecordTypes     = string.Join(",", ConvertToRecordType(this.DocumentType));

            if (this.ShouldProcess(this.Name, $"Update Application Insights Continuous Export {this.ExportId}"))
            {
                var exportResponse = this.AppInsightsManagementClient
                                     .ExportConfigurations
                                     .UpdateWithHttpMessagesAsync(
                    this.ResourceGroupName,
                    this.Name,
                    this.ExportId,
                    exportRequest)
                                     .GetAwaiter()
                                     .GetResult();

                WriteComponentExportConfiguration(exportResponse.Body);
            }
        }
 /// <summary>
 /// Create a Continuous Export configuration of an Application Insights
 /// component.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The name of the resource group.
 /// </param>
 /// <param name='resourceName'>
 /// The name of the Application Insights component resource.
 /// </param>
 /// <param name='exportProperties'>
 /// Properties that need to be specified to create a Continuous Export
 /// configuration of a Application Insights component.
 /// </param>
 public static IList <ApplicationInsightsComponentExportConfiguration> Create(this IExportConfigurationsOperations operations, string resourceGroupName, string resourceName, ApplicationInsightsComponentExportRequest exportProperties)
 {
     return(operations.CreateAsync(resourceGroupName, resourceName, exportProperties).GetAwaiter().GetResult());
 }
 /// <summary>
 /// Update the Continuous Export configuration for this export id.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The name of the resource group.
 /// </param>
 /// <param name='resourceName'>
 /// The name of the Application Insights component resource.
 /// </param>
 /// <param name='exportId'>
 /// The Continuous Export configuration ID. This is unique within a Application
 /// Insights component.
 /// </param>
 /// <param name='exportProperties'>
 /// Properties that need to be specified to update the Continuous Export
 /// configuration.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <ApplicationInsightsComponentExportConfiguration> UpdateAsync(this IExportConfigurationsOperations operations, string resourceGroupName, string resourceName, string exportId, ApplicationInsightsComponentExportRequest exportProperties, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, resourceName, exportId, exportProperties, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }