コード例 #1
0
        protected override void RunCmdlet()
        {
            if (string.Equals(
                    this.ParameterSetName,
                    GetAzureMLWebServiceKeys.GetKeysByInstance,
                    StringComparison.OrdinalIgnoreCase))
            {
                string subscriptionId, resourceGroup, webServiceName;
                if (!CmdletHelpers.TryParseMlResourceMetadataFromResourceId(
                        this.MlWebService.Id,
                        out subscriptionId,
                        out resourceGroup,
                        out webServiceName))
                {
                    throw new ValidationMetadataException(Resources.InvalidWebServiceIdOnObject);
                }

                this.ResourceGroupName = resourceGroup;
                this.Name = webServiceName;
            }

            WebServiceKeys storageKeys =
                this.WebServicesClient.GetAzureMlWebServiceKeys(this.ResourceGroupName, this.Name);

            this.WriteObject(storageKeys);
        }
コード例 #2
0
        public void CreateGetRemoveGraphWebService()
        {
            this.RunAMLWebServiceTestScenario((webServiceName, resourceGroupName, resourcesClient, amlServicesClient, cpResourceId, storageAccount) =>
            {
                bool serviceWasRemoved = false;
                try
                {
                    //Validate expected NO-OP behavior on deleting a non existing service
                    amlServicesClient.WebServices.RemoveWithRequestId(resourceGroupName, webServiceName);

                    // Create and validate the AML service resource
                    var serviceDefinition = WebServiceTests.GetServiceDefinitionFromTestData(this.TestServiceDefinitionFile, cpResourceId, storageAccount);
                    var webService        = amlServicesClient.WebServices.CreateOrUpdateWithRequestId(serviceDefinition, resourceGroupName, webServiceName);
                    WebServiceTests.ValidateWebServiceResource(amlServicesClient.SubscriptionId, resourceGroupName, webServiceName, webService, serviceDefinition);

                    // Retrieve the AML web service after creation
                    var retrievedService = amlServicesClient.WebServices.Get(resourceGroupName, webServiceName);
                    WebServiceTests.ValidateWebServiceResource(amlServicesClient.SubscriptionId, resourceGroupName, webServiceName, retrievedService);

                    // Retrieve the AML web service's keys
                    WebServiceKeys serviceKeys = amlServicesClient.WebServices.ListKeys(resourceGroupName, webServiceName);
                    Assert.NotNull(serviceKeys);
                    Assert.Equal(serviceKeys.Primary, serviceDefinition.Properties.Keys.Primary);
                    Assert.Equal(serviceKeys.Secondary, serviceDefinition.Properties.Keys.Secondary);

                    // Remove the web service
                    amlServicesClient.WebServices.RemoveWithRequestId(resourceGroupName, webServiceName);
                    serviceWasRemoved = true;

                    //Validate that the expected not found exception is thrown after deletion when trying to access the service
                    var expectedCloudException = Assert.Throws <CloudException>(() => amlServicesClient.WebServices.Get(resourceGroupName, webServiceName));
                    Assert.NotNull(expectedCloudException.Body);
                    Assert.Equal("NotFound", expectedCloudException.Body.Code);
                }
                catch (Exception ex)
                {
                    Trace.TraceError("Caught unexpected exception: ");
                    Trace.TraceError(ex.Message);

                    throw;
                }
                finally
                {
                    // Remove the web service
                    if (!serviceWasRemoved)
                    {
                        BaseScenarioTests.DisposeOfTestResource(() => amlServicesClient.WebServices.RemoveWithRequestId(resourceGroupName, webServiceName));
                    }
                }
            });
        }
コード例 #3
0
        public void CreateAndUpdateOnGraphWebService()
        {
            this.RunAMLWebServiceTestScenario((webServiceName, resourceGroupName, resourcesClient, amlServicesClient, cpResourceId, storageAccount) =>
            {
                try
                {
                    // Create and validate the AML service resource
                    var serviceDefinition = WebServiceTests.GetServiceDefinitionFromTestData(this.TestServiceDefinitionFile, cpResourceId, storageAccount);
                    var webService        = amlServicesClient.WebServices.CreateOrUpdateWithRequestId(serviceDefinition, resourceGroupName, webServiceName);
                    WebServiceTests.ValidateWebServiceResource(amlServicesClient.SubscriptionId, resourceGroupName, webServiceName, webService, serviceDefinition);

                    // Submit some updates to this resource
                    var serviceUpdates = new WebService
                    {
                        Properties = new WebServicePropertiesForGraph
                        {
                            Description = "description was updated!",
                            Keys        = new WebServiceKeys("f6ae3d003c63457ab4c5997effb5e4dc"),
                            Diagnostics = new DiagnosticsConfiguration(DiagnosticsLevel.All)
                        }
                    };
                    var updatedWebService = amlServicesClient.WebServices.PatchWithRequestId(serviceUpdates, resourceGroupName, webServiceName);

                    // Validate the updated resource
                    WebServiceTests.ValidateWebServiceResource(amlServicesClient.SubscriptionId, resourceGroupName, webServiceName, updatedWebService);
                    Assert.Equal(serviceUpdates.Properties.Description, updatedWebService.Properties.Description);
                    Assert.NotNull(updatedWebService.Properties.Diagnostics);
                    Assert.Equal(serviceUpdates.Properties.Diagnostics.Level, updatedWebService.Properties.Diagnostics.Level);
                    Assert.True(updatedWebService.Properties.ModifiedOn.Value.CompareTo(webService.Properties.ModifiedOn.Value) > 0);

                    // Also fetch the service keys and validate the update there
                    WebServiceKeys serviceKeys = amlServicesClient.WebServices.ListKeys(resourceGroupName, webServiceName);
                    Assert.NotNull(serviceKeys);
                    Assert.Equal(serviceKeys.Primary, serviceUpdates.Properties.Keys.Primary);
                    Assert.Equal(serviceKeys.Secondary, serviceDefinition.Properties.Keys.Secondary);
                }
                catch (Exception ex)
                {
                    Trace.TraceError("Caught unexpected exception: ");
                    Trace.TraceError(ex.Message);

                    throw;
                }
                finally
                {
                    // Remove the web service
                    BaseScenarioTests.DisposeOfTestResource(() => amlServicesClient.WebServices.RemoveWithRequestId(resourceGroupName, webServiceName));
                }
            });
        }