public virtual ApplicationDefinitionCreateOrUpdateOperation CreateOrUpdate(string applicationDefinitionName, ApplicationDefinitionData parameters, bool waitForCompletion = true, CancellationToken cancellationToken = default)
        {
            if (applicationDefinitionName == null)
            {
                throw new ArgumentNullException(nameof(applicationDefinitionName));
            }
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }

            using var scope = _clientDiagnostics.CreateScope("ApplicationDefinitionCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response  = _restClient.CreateOrUpdate(Id.ResourceGroupName, applicationDefinitionName, parameters, cancellationToken);
                var operation = new ApplicationDefinitionCreateOrUpdateOperation(Parent, _clientDiagnostics, Pipeline, _restClient.CreateCreateOrUpdateRequest(Id.ResourceGroupName, applicationDefinitionName, parameters).Request, response);
                if (waitForCompletion)
                {
                    operation.WaitForCompletion(cancellationToken);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
예제 #2
0
        public async virtual Task <ApplicationDefinitionCreateOrUpdateOperation> CreateOrUpdateAsync(bool waitForCompletion, string applicationDefinitionName, ApplicationDefinitionData parameters, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(applicationDefinitionName, nameof(applicationDefinitionName));
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }

            using var scope = _applicationDefinitionClientDiagnostics.CreateScope("ApplicationDefinitionCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response = await _applicationDefinitionRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, applicationDefinitionName, parameters, cancellationToken).ConfigureAwait(false);

                var operation = new ApplicationDefinitionCreateOrUpdateOperation(ArmClient, _applicationDefinitionClientDiagnostics, Pipeline, _applicationDefinitionRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, applicationDefinitionName, parameters).Request, response);
                if (waitForCompletion)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
예제 #3
0
        public async Task CreateApplicationDefinitions()
        {
            #region Snippet:Managing_ApplicationDefinitions_CreateAnApplicationDefinition
            // First we need to get the application definition collection from the resource group
            ApplicationDefinitionCollection applicationDefinitionCollection = resourceGroup.GetApplicationDefinitions();
            // Use the same location as the resource group
            string applicationDefinitionName = "myApplicationDefinition";
            var    input = new ApplicationDefinitionData(resourceGroup.Data.Location, ApplicationLockLevel.None)
            {
                DisplayName    = applicationDefinitionName,
                Description    = $"{applicationDefinitionName} description",
                PackageFileUri = "https://raw.githubusercontent.com/Azure/azure-managedapp-samples/master/Managed%20Application%20Sample%20Packages/201-managed-storage-account/managedstorage.zip"
            };
            ApplicationDefinitionCreateOrUpdateOperation lro = await applicationDefinitionCollection.CreateOrUpdateAsync(true, applicationDefinitionName, input);

            ApplicationDefinition applicationDefinition = lro.Value;
            #endregion Snippet:Managing_ApplicationDefinitions_CreateAnApplicationDefinition
        }