コード例 #1
0
        protected override void ProcessRecordInternal()
        {
            base.ProcessRecordInternal();

            AzureMonitorPrivateLinkScope existingScope = null;

            try
            {
                existingScope = this.getExistingScope(this.ResourceGroupName, this.Name);
            }
            catch
            {
                existingScope = null;
            }

            if (existingScope != null)
            {
                throw new PSInvalidOperationException(string.Format("A Private Link Scope with name: '{0}' in resource group: '{1}' already exists. Please use Update-AzInsightsPrivateLinkScope to update an existing scope.", this.Name, this.ResourceGroupName));
            }

            AzureMonitorPrivateLinkScope payLoad = new AzureMonitorPrivateLinkScope(this.Location);

            if (this.IsParameterBound(c => c.Tags))
            {
                payLoad.Tags = this.Tags.ToDictionary(s => s.Split(':')[0], s => s.Split(':')[1]);
            }

            if (ShouldProcess(this.Name, string.Format("create scope: {0} under resource group: {1}", this.Name, this.ResourceGroupName)))
            {
                var response = this.MonitorManagementClient
                               .PrivateLinkScopes
                               .CreateOrUpdateWithHttpMessagesAsync(this.ResourceGroupName, this.Name, payLoad)
                               .Result;
                WriteObject(PSMapper.Instance.Map <PSMonitorPrivateLinkScope>(response.Body));
            }
        }
 /// <summary>
 /// Creates (or updates) a Azure Monitor PrivateLinkScope. Note: You cannot
 /// specify a different value for InstrumentationKey nor AppId in the Put
 /// operation.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The name of the resource group. The name is case insensitive.
 /// </param>
 /// <param name='scopeName'>
 /// The name of the Azure Monitor PrivateLinkScope resource.
 /// </param>
 /// <param name='azureMonitorPrivateLinkScopePayload'>
 /// Properties that need to be specified to create or update a Azure Monitor
 /// PrivateLinkScope.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <AzureMonitorPrivateLinkScope> CreateOrUpdateAsync(this IPrivateLinkScopesOperations operations, string resourceGroupName, string scopeName, AzureMonitorPrivateLinkScope azureMonitorPrivateLinkScopePayload, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, scopeName, azureMonitorPrivateLinkScopePayload, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
 /// <summary>
 /// Creates (or updates) a Azure Monitor PrivateLinkScope. Note: You cannot
 /// specify a different value for InstrumentationKey nor AppId in the Put
 /// operation.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The name of the resource group. The name is case insensitive.
 /// </param>
 /// <param name='scopeName'>
 /// The name of the Azure Monitor PrivateLinkScope resource.
 /// </param>
 /// <param name='azureMonitorPrivateLinkScopePayload'>
 /// Properties that need to be specified to create or update a Azure Monitor
 /// PrivateLinkScope.
 /// </param>
 public static AzureMonitorPrivateLinkScope CreateOrUpdate(this IPrivateLinkScopesOperations operations, string resourceGroupName, string scopeName, AzureMonitorPrivateLinkScope azureMonitorPrivateLinkScopePayload)
 {
     return(operations.CreateOrUpdateAsync(resourceGroupName, scopeName, azureMonitorPrivateLinkScopePayload).GetAwaiter().GetResult());
 }