diff --git a/src/CognitiveServices/CognitiveServices.Test/CognitiveServices.Test.csproj b/src/CognitiveServices/CognitiveServices.Test/CognitiveServices.Test.csproj index e0d1f918010e..d10acef03fb8 100644 --- a/src/CognitiveServices/CognitiveServices.Test/CognitiveServices.Test.csproj +++ b/src/CognitiveServices/CognitiveServices.Test/CognitiveServices.Test.csproj @@ -1,4 +1,4 @@ - + CognitiveServices @@ -11,7 +11,7 @@ - + diff --git a/src/CognitiveServices/CognitiveServices.Test/ScenarioTests/CognitiveServicesAccountTests.cs b/src/CognitiveServices/CognitiveServices.Test/ScenarioTests/CognitiveServicesAccountTests.cs index 68362a734b25..892b277ebde8 100644 --- a/src/CognitiveServices/CognitiveServices.Test/ScenarioTests/CognitiveServicesAccountTests.cs +++ b/src/CognitiveServices/CognitiveServices.Test/ScenarioTests/CognitiveServicesAccountTests.cs @@ -84,6 +84,14 @@ public void TestGetAccounts() { TestController.NewInstance.RunPsTest(traceInterceptor, "Test-GetAzureCognitiveServiceAccount"); } + + [Fact] + [Trait(Category.AcceptanceType, Category.CheckIn)] + public void TestAsyncAccountOperations() + { + TestController.NewInstance.RunPsTest(traceInterceptor, "Test-AsyncAccountOperations"); + } + [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void TestSetAccount() diff --git a/src/CognitiveServices/CognitiveServices.Test/ScenarioTests/CognitiveServicesAccountTests.ps1 b/src/CognitiveServices/CognitiveServices.Test/ScenarioTests/CognitiveServicesAccountTests.ps1 index 2f3275c9f020..0ae6d9ea639f 100644 --- a/src/CognitiveServices/CognitiveServices.Test/ScenarioTests/CognitiveServicesAccountTests.ps1 +++ b/src/CognitiveServices/CognitiveServices.Test/ScenarioTests/CognitiveServicesAccountTests.ps1 @@ -114,6 +114,36 @@ function Test-NewAzureRmAllKindsOfCognitiveServicesAccounts } } + +<# +.SYNOPSIS +Test AsyncAccountOperations +#> +function Test-AsyncAccountOperations +{ + # Setup + $rgname = Get-CognitiveServicesManagementTestResourceName; + + try + { + # Test + $accountname = 'csa' + $rgname; + $skuname = 'S0'; + $accounttype = 'Personalizer'; + $loc = Get-Location -providerNamespace "Microsoft.CognitiveServices" -resourceType "accounts" -preferredLocation "West US 2"; + + New-AzResourceGroup -Name $rgname -Location $loc; + + $createdAccount = New-AzCognitiveServicesAccount -ResourceGroupName $rgname -Name $accountname -Type $accounttype -SkuName $skuname -Location $loc -Force; + Remove-AzCognitiveServicesAccount -ResourceGroupName $rgname -Name $accountname -Force; + } + finally + { + # Cleanup + Clean-ResourceGroup $rgname + } +} + <# .SYNOPSIS Test Remove-AzCognitiveServicesAccount diff --git a/src/CognitiveServices/CognitiveServices.Test/SessionRecords/CognitiveServices.Test.ScenarioTests.CognitiveServicesAccountTests/TestAsyncAccountOperations.json b/src/CognitiveServices/CognitiveServices.Test/SessionRecords/CognitiveServices.Test.ScenarioTests.CognitiveServicesAccountTests/TestAsyncAccountOperations.json new file mode 100644 index 000000000000..e914bff0a901 --- /dev/null +++ b/src/CognitiveServices/CognitiveServices.Test/SessionRecords/CognitiveServices.Test.ScenarioTests.CognitiveServicesAccountTests/TestAsyncAccountOperations.json @@ -0,0 +1,633 @@ +{ + "Entries": [ + { + "RequestUri": "/subscriptions/f9b96b36-1f5e-4021-8959-51527e26e6d3/providers/Microsoft.CognitiveServices?api-version=2016-09-01", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvZjliOTZiMzYtMWY1ZS00MDIxLTg5NTktNTE1MjdlMjZlNmQzL3Byb3ZpZGVycy9NaWNyb3NvZnQuQ29nbml0aXZlU2VydmljZXM/YXBpLXZlcnNpb249MjAxNi0wOS0wMQ==", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "x-ms-client-request-id": [ + "cd0f0258-8a3f-48d2-adc1-eb294c32a4a6" + ], + "Accept-Language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.28207.04", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.18363.", + "Microsoft.Azure.Management.Internal.Resources.ResourceManagementClient/1.3.4" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Pragma": [ + "no-cache" + ], + "x-ms-ratelimit-remaining-subscription-reads": [ + "11998" + ], + "x-ms-request-id": [ + "c54ad80a-3dfc-408b-bbc4-6647dbf54f9b" + ], + "x-ms-correlation-request-id": [ + "c54ad80a-3dfc-408b-bbc4-6647dbf54f9b" + ], + "x-ms-routing-request-id": [ + "WESTUS:20200114T032612Z:c54ad80a-3dfc-408b-bbc4-6647dbf54f9b" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Date": [ + "Tue, 14 Jan 2020 03:26:11 GMT" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ], + "Content-Length": [ + "3404" + ] + }, + "ResponseBody": "{\r\n \"id\": \"/subscriptions/f9b96b36-1f5e-4021-8959-51527e26e6d3/providers/Microsoft.CognitiveServices\",\r\n \"namespace\": \"Microsoft.CognitiveServices\",\r\n \"authorizations\": [\r\n {\r\n \"applicationId\": \"7d312290-28c8-473c-a0ed-8e53749b6d6d\",\r\n \"roleDefinitionId\": \"5cb87f79-a7c3-4a95-9414-45b65974b51b\"\r\n }\r\n ],\r\n \"resourceTypes\": [\r\n {\r\n \"resourceType\": \"accounts\",\r\n \"locations\": [\r\n \"Global\",\r\n \"Australia East\",\r\n \"Brazil South\",\r\n \"West US\",\r\n \"West US 2\",\r\n \"West Europe\",\r\n \"North Europe\",\r\n \"Southeast Asia\",\r\n \"East Asia\",\r\n \"West Central US\",\r\n \"South Central US\",\r\n \"East US\",\r\n \"East US 2\",\r\n \"Canada Central\",\r\n \"Japan East\",\r\n \"Central India\",\r\n \"UK South\",\r\n \"Japan West\",\r\n \"Korea Central\",\r\n \"France Central\",\r\n \"North Central US\",\r\n \"Central US\",\r\n \"South Africa North\",\r\n \"UAE North\",\r\n \"Central US EUAP\"\r\n ],\r\n \"apiVersions\": [\r\n \"2017-04-18\",\r\n \"2016-02-01-preview\"\r\n ],\r\n \"capabilities\": \"CrossResourceGroupResourceMove, CrossSubscriptionResourceMove\"\r\n },\r\n {\r\n \"resourceType\": \"operations\",\r\n \"locations\": [\r\n \"Global\",\r\n \"Australia East\",\r\n \"Brazil South\",\r\n \"West US\",\r\n \"West US 2\",\r\n \"West Europe\",\r\n \"North Europe\",\r\n \"Southeast Asia\",\r\n \"East Asia\",\r\n \"West Central US\",\r\n \"South Central US\",\r\n \"East US\",\r\n \"East US 2\",\r\n \"Canada Central\",\r\n \"Japan East\",\r\n \"Central India\",\r\n \"UK South\",\r\n \"Japan West\",\r\n \"Korea Central\",\r\n \"France Central\",\r\n \"North Central US\",\r\n \"Central US\",\r\n \"South Africa North\",\r\n \"UAE North\",\r\n \"Central US EUAP\"\r\n ],\r\n \"apiVersions\": [\r\n \"2017-04-18\",\r\n \"2016-02-01-preview\"\r\n ]\r\n },\r\n {\r\n \"resourceType\": \"locations/operationResults\",\r\n \"locations\": [\r\n \"Global\",\r\n \"Australia East\",\r\n \"Brazil South\",\r\n \"West US\",\r\n \"West US 2\",\r\n \"West Europe\",\r\n \"North Europe\",\r\n \"Southeast Asia\",\r\n \"East Asia\",\r\n \"West Central US\",\r\n \"South Central US\",\r\n \"East US\",\r\n \"East US 2\",\r\n \"Canada Central\",\r\n \"Japan East\",\r\n \"Central India\",\r\n \"UK South\",\r\n \"Japan West\",\r\n \"Korea Central\",\r\n \"France Central\",\r\n \"North Central US\",\r\n \"Central US\",\r\n \"South Africa North\",\r\n \"UAE North\",\r\n \"Central US EUAP\"\r\n ],\r\n \"apiVersions\": [\r\n \"2017-04-18\",\r\n \"2016-02-01-preview\"\r\n ]\r\n },\r\n {\r\n \"resourceType\": \"locations\",\r\n \"locations\": [\r\n \"Global\",\r\n \"Australia East\",\r\n \"Brazil South\",\r\n \"West US\",\r\n \"West US 2\",\r\n \"West Europe\",\r\n \"North Europe\",\r\n \"Southeast Asia\",\r\n \"East Asia\",\r\n \"West Central US\",\r\n \"South Central US\",\r\n \"East US\",\r\n \"East US 2\",\r\n \"Canada Central\",\r\n \"Japan East\",\r\n \"Central India\",\r\n \"UK South\",\r\n \"Japan West\",\r\n \"Korea Central\",\r\n \"France Central\",\r\n \"North Central US\",\r\n \"Central US\",\r\n \"South Africa North\",\r\n \"UAE North\",\r\n \"Central US EUAP\"\r\n ],\r\n \"apiVersions\": [\r\n \"2017-04-18\",\r\n \"2016-02-01-preview\"\r\n ]\r\n },\r\n {\r\n \"resourceType\": \"locations/deleteVirtualNetworkOrSubnets\",\r\n \"locations\": [\r\n \"West US 2\",\r\n \"West Europe\",\r\n \"Central US EUAP\"\r\n ],\r\n \"apiVersions\": [\r\n \"2017-04-18\",\r\n \"2016-02-01-preview\"\r\n ]\r\n },\r\n {\r\n \"resourceType\": \"locations/checkSkuAvailability\",\r\n \"locations\": [\r\n \"Global\",\r\n \"Australia East\",\r\n \"Brazil South\",\r\n \"West US\",\r\n \"West US 2\",\r\n \"West Europe\",\r\n \"North Europe\",\r\n \"Southeast Asia\",\r\n \"East Asia\",\r\n \"West Central US\",\r\n \"South Central US\",\r\n \"East US\",\r\n \"East US 2\",\r\n \"Canada Central\",\r\n \"Japan East\",\r\n \"Central India\",\r\n \"UK South\",\r\n \"Japan West\",\r\n \"Korea Central\",\r\n \"France Central\",\r\n \"North Central US\",\r\n \"Central US\",\r\n \"South Africa North\",\r\n \"UAE North\",\r\n \"Central US EUAP\"\r\n ],\r\n \"apiVersions\": [\r\n \"2017-04-18\",\r\n \"2016-02-01-preview\"\r\n ]\r\n },\r\n {\r\n \"resourceType\": \"checkDomainAvailability\",\r\n \"locations\": [],\r\n \"apiVersions\": [\r\n \"2017-04-18\"\r\n ]\r\n },\r\n {\r\n \"resourceType\": \"locations/updateAccountsCreationSettings\",\r\n \"locations\": [\r\n \"West US\",\r\n \"Global\",\r\n \"West Europe\",\r\n \"Southeast Asia\",\r\n \"West Central US\",\r\n \"East US 2\",\r\n \"UAE North\"\r\n ],\r\n \"apiVersions\": [\r\n \"2017-04-18\",\r\n \"2016-02-01-preview\"\r\n ]\r\n },\r\n {\r\n \"resourceType\": \"locations/accountsCreationSettings\",\r\n \"locations\": [\r\n \"West US\",\r\n \"Global\",\r\n \"West Europe\",\r\n \"Southeast Asia\",\r\n \"West Central US\",\r\n \"East US 2\",\r\n \"UAE North\"\r\n ],\r\n \"apiVersions\": [\r\n \"2016-02-01-preview\"\r\n ]\r\n }\r\n ],\r\n \"registrationState\": \"Registered\"\r\n}", + "StatusCode": 200 + }, + { + "RequestUri": "/subscriptions/f9b96b36-1f5e-4021-8959-51527e26e6d3/resourcegroups/pstestrg182?api-version=2016-09-01", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvZjliOTZiMzYtMWY1ZS00MDIxLTg5NTktNTE1MjdlMjZlNmQzL3Jlc291cmNlZ3JvdXBzL3BzdGVzdHJnMTgyP2FwaS12ZXJzaW9uPTIwMTYtMDktMDE=", + "RequestMethod": "PUT", + "RequestBody": "{\r\n \"location\": \"West US 2\"\r\n}", + "RequestHeaders": { + "x-ms-client-request-id": [ + "cf2e6afc-2040-42c3-a61f-2426d708c9f3" + ], + "Accept-Language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.28207.04", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.18363.", + "Microsoft.Azure.Management.Internal.Resources.ResourceManagementClient/1.3.4" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Content-Length": [ + "31" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Pragma": [ + "no-cache" + ], + "x-ms-ratelimit-remaining-subscription-writes": [ + "1199" + ], + "x-ms-request-id": [ + "058eccd5-723b-4287-b5bf-2604b161cc12" + ], + "x-ms-correlation-request-id": [ + "058eccd5-723b-4287-b5bf-2604b161cc12" + ], + "x-ms-routing-request-id": [ + "WESTUS:20200114T032613Z:058eccd5-723b-4287-b5bf-2604b161cc12" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Date": [ + "Tue, 14 Jan 2020 03:26:13 GMT" + ], + "Content-Length": [ + "176" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "{\r\n \"id\": \"/subscriptions/f9b96b36-1f5e-4021-8959-51527e26e6d3/resourceGroups/pstestrg182\",\r\n \"name\": \"pstestrg182\",\r\n \"location\": \"westus2\",\r\n \"properties\": {\r\n \"provisioningState\": \"Succeeded\"\r\n }\r\n}", + "StatusCode": 201 + }, + { + "RequestUri": "/subscriptions/f9b96b36-1f5e-4021-8959-51527e26e6d3/resourceGroups/pstestrg182/providers/Microsoft.CognitiveServices/accounts/csapstestrg182?api-version=2017-04-18", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvZjliOTZiMzYtMWY1ZS00MDIxLTg5NTktNTE1MjdlMjZlNmQzL3Jlc291cmNlR3JvdXBzL3BzdGVzdHJnMTgyL3Byb3ZpZGVycy9NaWNyb3NvZnQuQ29nbml0aXZlU2VydmljZXMvYWNjb3VudHMvY3NhcHN0ZXN0cmcxODI/YXBpLXZlcnNpb249MjAxNy0wNC0xOA==", + "RequestMethod": "PUT", + "RequestBody": "{\r\n \"sku\": {\r\n \"name\": \"S0\"\r\n },\r\n \"kind\": \"Personalizer\",\r\n \"location\": \"West US 2\",\r\n \"properties\": {}\r\n}", + "RequestHeaders": { + "x-ms-client-request-id": [ + "3af22f6e-2123-4e9c-8763-ef6c122e6b5f" + ], + "Accept-Language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.28207.04", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.18363.", + "Microsoft.Azure.Management.CognitiveServices.CognitiveServicesManagementClient/6.0.0.0" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Content-Length": [ + "115" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Pragma": [ + "no-cache" + ], + "ETag": [ + "\"01002743-0000-0800-0000-5e1d34dc0000\"" + ], + "x-ms-request-id": [ + "55fc5e8e-1e13-41e7-9cc5-0e4d59033bf2" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "Server": [ + "Microsoft-IIS/10.0" + ], + "X-AspNet-Version": [ + "4.0.30319" + ], + "X-Powered-By": [ + "ASP.NET" + ], + "x-ms-ratelimit-remaining-subscription-writes": [ + "1199" + ], + "x-ms-correlation-request-id": [ + "82484c36-20fc-49ed-a4cc-363f2c5148ca" + ], + "x-ms-routing-request-id": [ + "WESTUS:20200114T032621Z:82484c36-20fc-49ed-a4cc-363f2c5148ca" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Date": [ + "Tue, 14 Jan 2020 03:26:20 GMT" + ], + "Content-Length": [ + "865" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "{\r\n \"id\": \"/subscriptions/f9b96b36-1f5e-4021-8959-51527e26e6d3/resourceGroups/pstestrg182/providers/Microsoft.CognitiveServices/accounts/csapstestrg182\",\r\n \"name\": \"csapstestrg182\",\r\n \"type\": \"Microsoft.CognitiveServices/accounts\",\r\n \"etag\": \"\\\"01002743-0000-0800-0000-5e1d34dc0000\\\"\",\r\n \"location\": \"West US 2\",\r\n \"sku\": {\r\n \"name\": \"S0\"\r\n },\r\n \"kind\": \"Personalizer\",\r\n \"properties\": {\r\n \"endpoint\": \"https://westus2.api.cognitive.microsoft.com/\",\r\n \"internalId\": \"7a6376eace494e6fafedd66e075617b0\",\r\n \"dateCreated\": \"2020-01-14T03:26:20.6162546Z\",\r\n \"callRateLimit\": {\r\n \"rules\": [\r\n {\r\n \"key\": \"personalizer.rankreward\",\r\n \"renewalPeriod\": 1,\r\n \"count\": 2000,\r\n \"matchPatterns\": [\r\n {\r\n \"path\": \"personalizer/v1.0/rank\",\r\n \"method\": \"POST\"\r\n },\r\n {\r\n \"path\": \"personalizer/v1.0/{eventId}/reward\",\r\n \"method\": \"POST\"\r\n }\r\n ]\r\n },\r\n {\r\n \"key\": \"default\",\r\n \"renewalPeriod\": 1,\r\n \"count\": 500,\r\n \"matchPatterns\": [\r\n {\r\n \"path\": \"personalizer/v1.0/*\",\r\n \"method\": \"*\"\r\n }\r\n ]\r\n }\r\n ]\r\n },\r\n \"provisioningState\": \"Succeeded\"\r\n }\r\n}", + "StatusCode": 201 + }, + { + "RequestUri": "/subscriptions/f9b96b36-1f5e-4021-8959-51527e26e6d3/resourceGroups/pstestrg182/providers/Microsoft.CognitiveServices/accounts/csapstestrg182?api-version=2017-04-18", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvZjliOTZiMzYtMWY1ZS00MDIxLTg5NTktNTE1MjdlMjZlNmQzL3Jlc291cmNlR3JvdXBzL3BzdGVzdHJnMTgyL3Byb3ZpZGVycy9NaWNyb3NvZnQuQ29nbml0aXZlU2VydmljZXMvYWNjb3VudHMvY3NhcHN0ZXN0cmcxODI/YXBpLXZlcnNpb249MjAxNy0wNC0xOA==", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "x-ms-client-request-id": [ + "ce8dfabb-d3b1-4148-9b0a-e7ea98bc80ae" + ], + "Accept-Language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.28207.04", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.18363.", + "Microsoft.Azure.Management.CognitiveServices.CognitiveServicesManagementClient/6.0.0.0" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Pragma": [ + "no-cache" + ], + "ETag": [ + "\"01002743-0000-0800-0000-5e1d34dc0000\"" + ], + "x-ms-request-id": [ + "b30fa801-1275-4b2b-95b5-98813220cb72" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "Server": [ + "Microsoft-IIS/10.0" + ], + "X-AspNet-Version": [ + "4.0.30319" + ], + "X-Powered-By": [ + "ASP.NET" + ], + "x-ms-ratelimit-remaining-subscription-reads": [ + "11999" + ], + "x-ms-correlation-request-id": [ + "28bed3f2-d913-4cc7-a644-1fa7f920b960" + ], + "x-ms-routing-request-id": [ + "WESTUS:20200114T032630Z:28bed3f2-d913-4cc7-a644-1fa7f920b960" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Date": [ + "Tue, 14 Jan 2020 03:26:30 GMT" + ], + "Content-Length": [ + "865" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "{\r\n \"id\": \"/subscriptions/f9b96b36-1f5e-4021-8959-51527e26e6d3/resourceGroups/pstestrg182/providers/Microsoft.CognitiveServices/accounts/csapstestrg182\",\r\n \"name\": \"csapstestrg182\",\r\n \"type\": \"Microsoft.CognitiveServices/accounts\",\r\n \"etag\": \"\\\"01002743-0000-0800-0000-5e1d34dc0000\\\"\",\r\n \"location\": \"West US 2\",\r\n \"sku\": {\r\n \"name\": \"S0\"\r\n },\r\n \"kind\": \"Personalizer\",\r\n \"properties\": {\r\n \"endpoint\": \"https://westus2.api.cognitive.microsoft.com/\",\r\n \"internalId\": \"7a6376eace494e6fafedd66e075617b0\",\r\n \"dateCreated\": \"2020-01-14T03:26:20.6162546Z\",\r\n \"callRateLimit\": {\r\n \"rules\": [\r\n {\r\n \"key\": \"personalizer.rankreward\",\r\n \"renewalPeriod\": 1,\r\n \"count\": 2000,\r\n \"matchPatterns\": [\r\n {\r\n \"path\": \"personalizer/v1.0/rank\",\r\n \"method\": \"POST\"\r\n },\r\n {\r\n \"path\": \"personalizer/v1.0/{eventId}/reward\",\r\n \"method\": \"POST\"\r\n }\r\n ]\r\n },\r\n {\r\n \"key\": \"default\",\r\n \"renewalPeriod\": 1,\r\n \"count\": 500,\r\n \"matchPatterns\": [\r\n {\r\n \"path\": \"personalizer/v1.0/*\",\r\n \"method\": \"*\"\r\n }\r\n ]\r\n }\r\n ]\r\n },\r\n \"provisioningState\": \"Succeeded\"\r\n }\r\n}", + "StatusCode": 200 + }, + { + "RequestUri": "/subscriptions/f9b96b36-1f5e-4021-8959-51527e26e6d3/resourceGroups/pstestrg182/providers/Microsoft.CognitiveServices/accounts/csapstestrg182?api-version=2017-04-18", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvZjliOTZiMzYtMWY1ZS00MDIxLTg5NTktNTE1MjdlMjZlNmQzL3Jlc291cmNlR3JvdXBzL3BzdGVzdHJnMTgyL3Byb3ZpZGVycy9NaWNyb3NvZnQuQ29nbml0aXZlU2VydmljZXMvYWNjb3VudHMvY3NhcHN0ZXN0cmcxODI/YXBpLXZlcnNpb249MjAxNy0wNC0xOA==", + "RequestMethod": "DELETE", + "RequestBody": "", + "RequestHeaders": { + "x-ms-client-request-id": [ + "78a31a73-8325-49c4-8058-171f129d0c41" + ], + "Accept-Language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.28207.04", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.18363.", + "Microsoft.Azure.Management.CognitiveServices.CognitiveServicesManagementClient/6.0.0.0" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Pragma": [ + "no-cache" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "Server": [ + "Microsoft-IIS/10.0" + ], + "X-AspNet-Version": [ + "4.0.30319" + ], + "X-Powered-By": [ + "ASP.NET" + ], + "x-ms-ratelimit-remaining-subscription-deletes": [ + "14999" + ], + "x-ms-request-id": [ + "2be0e7d2-9ac0-47f5-a6c3-3f5ec8be16fe" + ], + "x-ms-correlation-request-id": [ + "2be0e7d2-9ac0-47f5-a6c3-3f5ec8be16fe" + ], + "x-ms-routing-request-id": [ + "WESTUS:20200114T032633Z:2be0e7d2-9ac0-47f5-a6c3-3f5ec8be16fe" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Date": [ + "Tue, 14 Jan 2020 03:26:32 GMT" + ], + "Expires": [ + "-1" + ], + "Content-Length": [ + "0" + ] + }, + "ResponseBody": "", + "StatusCode": 202 + }, + { + "RequestUri": "/subscriptions/f9b96b36-1f5e-4021-8959-51527e26e6d3/resourcegroups/pstestrg182?api-version=2016-09-01", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvZjliOTZiMzYtMWY1ZS00MDIxLTg5NTktNTE1MjdlMjZlNmQzL3Jlc291cmNlZ3JvdXBzL3BzdGVzdHJnMTgyP2FwaS12ZXJzaW9uPTIwMTYtMDktMDE=", + "RequestMethod": "DELETE", + "RequestBody": "", + "RequestHeaders": { + "x-ms-client-request-id": [ + "2e47565f-658b-44fd-97a2-276194924a86" + ], + "Accept-Language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.28207.04", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.18363.", + "Microsoft.Azure.Management.Internal.Resources.ResourceManagementClient/1.3.4" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Pragma": [ + "no-cache" + ], + "Location": [ + "https://management.azure.com/subscriptions/f9b96b36-1f5e-4021-8959-51527e26e6d3/operationresults/eyJqb2JJZCI6IlJFU09VUkNFR1JPVVBERUxFVElPTkpPQi1QU1RFU1RSRzE4Mi1XRVNUVVMyIiwiam9iTG9jYXRpb24iOiJ3ZXN0dXMyIn0?api-version=2016-09-01" + ], + "Retry-After": [ + "15" + ], + "x-ms-ratelimit-remaining-subscription-deletes": [ + "14999" + ], + "x-ms-request-id": [ + "ef819ed9-1893-44f4-8dfb-35079a063f33" + ], + "x-ms-correlation-request-id": [ + "ef819ed9-1893-44f4-8dfb-35079a063f33" + ], + "x-ms-routing-request-id": [ + "WESTUS:20200114T032633Z:ef819ed9-1893-44f4-8dfb-35079a063f33" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Date": [ + "Tue, 14 Jan 2020 03:26:33 GMT" + ], + "Expires": [ + "-1" + ], + "Content-Length": [ + "0" + ] + }, + "ResponseBody": "", + "StatusCode": 202 + }, + { + "RequestUri": "/subscriptions/f9b96b36-1f5e-4021-8959-51527e26e6d3/operationresults/eyJqb2JJZCI6IlJFU09VUkNFR1JPVVBERUxFVElPTkpPQi1QU1RFU1RSRzE4Mi1XRVNUVVMyIiwiam9iTG9jYXRpb24iOiJ3ZXN0dXMyIn0?api-version=2016-09-01", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvZjliOTZiMzYtMWY1ZS00MDIxLTg5NTktNTE1MjdlMjZlNmQzL29wZXJhdGlvbnJlc3VsdHMvZXlKcWIySkpaQ0k2SWxKRlUwOVZVa05GUjFKUFZWQkVSVXhGVkVsUFRrcFBRaTFRVTFSRlUxUlNSekU0TWkxWFJWTlVWVk15SWl3aWFtOWlURzlqWVhScGIyNGlPaUozWlhOMGRYTXlJbjA/YXBpLXZlcnNpb249MjAxNi0wOS0wMQ==", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "User-Agent": [ + "FxVersion/4.6.28207.04", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.18363.", + "Microsoft.Azure.Management.Internal.Resources.ResourceManagementClient/1.3.4" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Pragma": [ + "no-cache" + ], + "Location": [ + "https://management.azure.com/subscriptions/f9b96b36-1f5e-4021-8959-51527e26e6d3/operationresults/eyJqb2JJZCI6IlJFU09VUkNFR1JPVVBERUxFVElPTkpPQi1QU1RFU1RSRzE4Mi1XRVNUVVMyIiwiam9iTG9jYXRpb24iOiJ3ZXN0dXMyIn0?api-version=2016-09-01" + ], + "Retry-After": [ + "15" + ], + "x-ms-ratelimit-remaining-subscription-reads": [ + "11997" + ], + "x-ms-request-id": [ + "a1f869e1-3307-44fa-843f-f8e5cbef1908" + ], + "x-ms-correlation-request-id": [ + "a1f869e1-3307-44fa-843f-f8e5cbef1908" + ], + "x-ms-routing-request-id": [ + "WESTUS:20200114T032649Z:a1f869e1-3307-44fa-843f-f8e5cbef1908" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Date": [ + "Tue, 14 Jan 2020 03:26:48 GMT" + ], + "Expires": [ + "-1" + ], + "Content-Length": [ + "0" + ] + }, + "ResponseBody": "", + "StatusCode": 202 + }, + { + "RequestUri": "/subscriptions/f9b96b36-1f5e-4021-8959-51527e26e6d3/operationresults/eyJqb2JJZCI6IlJFU09VUkNFR1JPVVBERUxFVElPTkpPQi1QU1RFU1RSRzE4Mi1XRVNUVVMyIiwiam9iTG9jYXRpb24iOiJ3ZXN0dXMyIn0?api-version=2016-09-01", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvZjliOTZiMzYtMWY1ZS00MDIxLTg5NTktNTE1MjdlMjZlNmQzL29wZXJhdGlvbnJlc3VsdHMvZXlKcWIySkpaQ0k2SWxKRlUwOVZVa05GUjFKUFZWQkVSVXhGVkVsUFRrcFBRaTFRVTFSRlUxUlNSekU0TWkxWFJWTlVWVk15SWl3aWFtOWlURzlqWVhScGIyNGlPaUozWlhOMGRYTXlJbjA/YXBpLXZlcnNpb249MjAxNi0wOS0wMQ==", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "User-Agent": [ + "FxVersion/4.6.28207.04", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.18363.", + "Microsoft.Azure.Management.Internal.Resources.ResourceManagementClient/1.3.4" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Pragma": [ + "no-cache" + ], + "Location": [ + "https://management.azure.com/subscriptions/f9b96b36-1f5e-4021-8959-51527e26e6d3/operationresults/eyJqb2JJZCI6IlJFU09VUkNFR1JPVVBERUxFVElPTkpPQi1QU1RFU1RSRzE4Mi1XRVNUVVMyIiwiam9iTG9jYXRpb24iOiJ3ZXN0dXMyIn0?api-version=2016-09-01" + ], + "Retry-After": [ + "15" + ], + "x-ms-ratelimit-remaining-subscription-reads": [ + "11996" + ], + "x-ms-request-id": [ + "003671ba-b35a-4536-8efd-d9213b2ad6e5" + ], + "x-ms-correlation-request-id": [ + "003671ba-b35a-4536-8efd-d9213b2ad6e5" + ], + "x-ms-routing-request-id": [ + "WESTUS:20200114T032704Z:003671ba-b35a-4536-8efd-d9213b2ad6e5" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Date": [ + "Tue, 14 Jan 2020 03:27:03 GMT" + ], + "Expires": [ + "-1" + ], + "Content-Length": [ + "0" + ] + }, + "ResponseBody": "", + "StatusCode": 202 + }, + { + "RequestUri": "/subscriptions/f9b96b36-1f5e-4021-8959-51527e26e6d3/operationresults/eyJqb2JJZCI6IlJFU09VUkNFR1JPVVBERUxFVElPTkpPQi1QU1RFU1RSRzE4Mi1XRVNUVVMyIiwiam9iTG9jYXRpb24iOiJ3ZXN0dXMyIn0?api-version=2016-09-01", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvZjliOTZiMzYtMWY1ZS00MDIxLTg5NTktNTE1MjdlMjZlNmQzL29wZXJhdGlvbnJlc3VsdHMvZXlKcWIySkpaQ0k2SWxKRlUwOVZVa05GUjFKUFZWQkVSVXhGVkVsUFRrcFBRaTFRVTFSRlUxUlNSekU0TWkxWFJWTlVWVk15SWl3aWFtOWlURzlqWVhScGIyNGlPaUozWlhOMGRYTXlJbjA/YXBpLXZlcnNpb249MjAxNi0wOS0wMQ==", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "User-Agent": [ + "FxVersion/4.6.28207.04", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.18363.", + "Microsoft.Azure.Management.Internal.Resources.ResourceManagementClient/1.3.4" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Pragma": [ + "no-cache" + ], + "x-ms-ratelimit-remaining-subscription-reads": [ + "11995" + ], + "x-ms-request-id": [ + "24caef89-aef1-48d5-9516-cf51ceaa529c" + ], + "x-ms-correlation-request-id": [ + "24caef89-aef1-48d5-9516-cf51ceaa529c" + ], + "x-ms-routing-request-id": [ + "WESTUS:20200114T032719Z:24caef89-aef1-48d5-9516-cf51ceaa529c" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Date": [ + "Tue, 14 Jan 2020 03:27:19 GMT" + ], + "Expires": [ + "-1" + ], + "Content-Length": [ + "0" + ] + }, + "ResponseBody": "", + "StatusCode": 200 + }, + { + "RequestUri": "/subscriptions/f9b96b36-1f5e-4021-8959-51527e26e6d3/operationresults/eyJqb2JJZCI6IlJFU09VUkNFR1JPVVBERUxFVElPTkpPQi1QU1RFU1RSRzE4Mi1XRVNUVVMyIiwiam9iTG9jYXRpb24iOiJ3ZXN0dXMyIn0?api-version=2016-09-01", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvZjliOTZiMzYtMWY1ZS00MDIxLTg5NTktNTE1MjdlMjZlNmQzL29wZXJhdGlvbnJlc3VsdHMvZXlKcWIySkpaQ0k2SWxKRlUwOVZVa05GUjFKUFZWQkVSVXhGVkVsUFRrcFBRaTFRVTFSRlUxUlNSekU0TWkxWFJWTlVWVk15SWl3aWFtOWlURzlqWVhScGIyNGlPaUozWlhOMGRYTXlJbjA/YXBpLXZlcnNpb249MjAxNi0wOS0wMQ==", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "User-Agent": [ + "FxVersion/4.6.28207.04", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.18363.", + "Microsoft.Azure.Management.Internal.Resources.ResourceManagementClient/1.3.4" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Pragma": [ + "no-cache" + ], + "x-ms-ratelimit-remaining-subscription-reads": [ + "11994" + ], + "x-ms-request-id": [ + "9240a7fd-bd92-4f96-b3f8-09fc0f792d6a" + ], + "x-ms-correlation-request-id": [ + "9240a7fd-bd92-4f96-b3f8-09fc0f792d6a" + ], + "x-ms-routing-request-id": [ + "WESTUS:20200114T032719Z:9240a7fd-bd92-4f96-b3f8-09fc0f792d6a" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Date": [ + "Tue, 14 Jan 2020 03:27:19 GMT" + ], + "Expires": [ + "-1" + ], + "Content-Length": [ + "0" + ] + }, + "ResponseBody": "", + "StatusCode": 200 + } + ], + "Names": { + "Test-AsyncAccountOperations": [ + "pstestrg182" + ] + }, + "Variables": { + "SubscriptionId": "f9b96b36-1f5e-4021-8959-51527e26e6d3" + } +} \ No newline at end of file diff --git a/src/CognitiveServices/CognitiveServices/ChangeLog.md b/src/CognitiveServices/CognitiveServices/ChangeLog.md index 90ea29a5d0db..35e5241cf00b 100644 --- a/src/CognitiveServices/CognitiveServices/ChangeLog.md +++ b/src/CognitiveServices/CognitiveServices/ChangeLog.md @@ -18,6 +18,8 @@ - Additional information about change #1 --> ## Upcoming Release +* Update SDK to 7.0 +* Improve error message when server responses empty body ## Version 1.2.2 * Update references in .psd1 to use relative path diff --git a/src/CognitiveServices/CognitiveServices/CognitiveServices.csproj b/src/CognitiveServices/CognitiveServices/CognitiveServices.csproj index f51c57e3d11c..dd0198c59e01 100644 --- a/src/CognitiveServices/CognitiveServices/CognitiveServices.csproj +++ b/src/CognitiveServices/CognitiveServices/CognitiveServices.csproj @@ -11,7 +11,7 @@ - + \ No newline at end of file diff --git a/src/CognitiveServices/CognitiveServices/CognitiveServicesAccount/AddAzureCognitiveServicesAccountNetworkRule.cs b/src/CognitiveServices/CognitiveServices/CognitiveServicesAccount/AddAzureCognitiveServicesAccountNetworkRule.cs index 68d6e482dbb9..dec8413e683a 100644 --- a/src/CognitiveServices/CognitiveServices/CognitiveServicesAccount/AddAzureCognitiveServicesAccountNetworkRule.cs +++ b/src/CognitiveServices/CognitiveServices/CognitiveServicesAccount/AddAzureCognitiveServicesAccountNetworkRule.cs @@ -99,7 +99,7 @@ public override void ExecuteCmdlet() var account = this.CognitiveServicesClient.Accounts.GetProperties( this.ResourceGroupName, this.Name); - NetworkRuleSet accountACL = account.NetworkAcls; + NetworkRuleSet accountACL = account.Properties.NetworkAcls; if (accountACL == null) { @@ -156,9 +156,16 @@ public override void ExecuteCmdlet() break; } - var properties = new JObject(); - properties["networkAcls"] = JToken.FromObject(accountACL); - this.CognitiveServicesClient.Accounts.Update(this.ResourceGroupName, this.Name, null, null, properties); + var properties = new CognitiveServicesAccountProperties(); + properties.NetworkAcls = accountACL; + this.CognitiveServicesClient.Accounts.Update( + this.ResourceGroupName, + this.Name, + new CognitiveServicesAccount() + { + Properties = properties + } + ); account = this.CognitiveServicesClient.Accounts.GetProperties(this.ResourceGroupName, this.Name); @@ -166,11 +173,11 @@ public override void ExecuteCmdlet() { case NetWorkRuleStringParameterSet: case NetworkRuleObjectParameterSet: - WriteObject(PSNetworkRuleSet.Create(account.NetworkAcls).VirtualNetworkRules); + WriteObject(PSNetworkRuleSet.Create(account.Properties.NetworkAcls).VirtualNetworkRules); break; case IpRuleStringParameterSet: case IpRuleObjectParameterSet: - WriteObject(PSNetworkRuleSet.Create(account.NetworkAcls).IpRules); + WriteObject(PSNetworkRuleSet.Create(account.Properties.NetworkAcls).IpRules); break; } } diff --git a/src/CognitiveServices/CognitiveServices/CognitiveServicesAccount/CognitiveServicesAccountBaseCmdlet.cs b/src/CognitiveServices/CognitiveServices/CognitiveServicesAccount/CognitiveServicesAccountBaseCmdlet.cs index 8c2fd131e858..4bfb246bfd4a 100644 --- a/src/CognitiveServices/CognitiveServices/CognitiveServicesAccount/CognitiveServicesAccountBaseCmdlet.cs +++ b/src/CognitiveServices/CognitiveServices/CognitiveServicesAccount/CognitiveServicesAccountBaseCmdlet.cs @@ -84,6 +84,11 @@ protected void RunCmdLet(Action action) } catch (ErrorException ex) { + if (ex.Body == null) + { + throw new PSInvalidOperationException(ex.Message, ex); + } + throw new PSInvalidOperationException(ex.Body.ErrorProperty.Message, ex); } } diff --git a/src/CognitiveServices/CognitiveServices/CognitiveServicesAccount/GetAzureCognitiveServicesAccountNetworkRuleSet.cs b/src/CognitiveServices/CognitiveServices/CognitiveServicesAccount/GetAzureCognitiveServicesAccountNetworkRuleSet.cs index 2d2eca6fb945..bf1cc0c9129a 100644 --- a/src/CognitiveServices/CognitiveServices/CognitiveServicesAccount/GetAzureCognitiveServicesAccountNetworkRuleSet.cs +++ b/src/CognitiveServices/CognitiveServices/CognitiveServicesAccount/GetAzureCognitiveServicesAccountNetworkRuleSet.cs @@ -48,9 +48,9 @@ public override void ExecuteCmdlet() this.ResourceGroupName, this.Name); - if (account != null && account.NetworkAcls != null) + if (account != null && account.Properties.NetworkAcls != null) { - WriteObject(PSNetworkRuleSet.Create(account.NetworkAcls)); + WriteObject(PSNetworkRuleSet.Create(account.Properties.NetworkAcls)); } } } diff --git a/src/CognitiveServices/CognitiveServices/CognitiveServicesAccount/NewAzureCognitiveServicesAccount.cs b/src/CognitiveServices/CognitiveServices/CognitiveServicesAccount/NewAzureCognitiveServicesAccount.cs index e8d8f504cde0..fac912bcf793 100644 --- a/src/CognitiveServices/CognitiveServices/CognitiveServicesAccount/NewAzureCognitiveServicesAccount.cs +++ b/src/CognitiveServices/CognitiveServices/CognitiveServicesAccount/NewAzureCognitiveServicesAccount.cs @@ -110,21 +110,21 @@ public override void ExecuteCmdlet() RunCmdLet(() => { - var properties = new JObject(); + var properties = new CognitiveServicesAccountProperties(); if (!string.IsNullOrWhiteSpace(CustomSubdomainName)) { - properties["customSubDomainName"] = CustomSubdomainName; + properties.CustomSubDomainName = CustomSubdomainName; } if (NetworkRuleSet != null) { - properties["networkAcls"] = JToken.FromObject(NetworkRuleSet); + properties.NetworkAcls = NetworkRuleSet.ToNetworkRuleSet(); } - CognitiveServicesAccountCreateParameters createParameters = new CognitiveServicesAccountCreateParameters() + CognitiveServicesAccount createParameters = new CognitiveServicesAccount() { Location = Location, Kind = Type, // must have value, mandatory parameter - Sku = new Sku(SkuName), + Sku = new Sku(SkuName, null), Tags = TagsConversionHelper.CreateTagDictionary(Tag), Properties = properties }; diff --git a/src/CognitiveServices/CognitiveServices/CognitiveServicesAccount/RemoveAzureCognitiveServicesAccountNetworkRule.cs b/src/CognitiveServices/CognitiveServices/CognitiveServicesAccount/RemoveAzureCognitiveServicesAccountNetworkRule.cs index e713bc2a5867..d583f79978ee 100644 --- a/src/CognitiveServices/CognitiveServices/CognitiveServicesAccount/RemoveAzureCognitiveServicesAccountNetworkRule.cs +++ b/src/CognitiveServices/CognitiveServices/CognitiveServicesAccount/RemoveAzureCognitiveServicesAccountNetworkRule.cs @@ -102,7 +102,7 @@ public override void ExecuteCmdlet() var account = this.CognitiveServicesClient.Accounts.GetProperties( this.ResourceGroupName, this.Name); - NetworkRuleSet accountACL = account.NetworkAcls; + NetworkRuleSet accountACL = account.Properties.NetworkAcls; if (accountACL == null) { @@ -152,9 +152,16 @@ public override void ExecuteCmdlet() } - var properties = new JObject(); - properties["networkAcls"] = JToken.FromObject(accountACL); - this.CognitiveServicesClient.Accounts.Update(this.ResourceGroupName, this.Name, null, null, properties); + var properties = new CognitiveServicesAccountProperties(); + properties.NetworkAcls = accountACL; + this.CognitiveServicesClient.Accounts.Update( + this.ResourceGroupName, + this.Name, + new CognitiveServicesAccount() + { + Properties = properties + } + ); account = this.CognitiveServicesClient.Accounts.GetProperties(this.ResourceGroupName, this.Name); @@ -162,11 +169,11 @@ public override void ExecuteCmdlet() { case NetWorkRuleStringParameterSet: case NetworkRuleObjectParameterSet: - WriteObject(PSNetworkRuleSet.Create(account.NetworkAcls).VirtualNetworkRules); + WriteObject(PSNetworkRuleSet.Create(account.Properties.NetworkAcls).VirtualNetworkRules); break; case IpRuleStringParameterSet: case IpRuleObjectParameterSet: - WriteObject(PSNetworkRuleSet.Create(account.NetworkAcls).IpRules); + WriteObject(PSNetworkRuleSet.Create(account.Properties.NetworkAcls).IpRules); break; } } diff --git a/src/CognitiveServices/CognitiveServices/CognitiveServicesAccount/SetAzureCognitiveServicesAccount.cs b/src/CognitiveServices/CognitiveServices/CognitiveServicesAccount/SetAzureCognitiveServicesAccount.cs index 5db738d3f212..fef02b1aba89 100644 --- a/src/CognitiveServices/CognitiveServices/CognitiveServicesAccount/SetAzureCognitiveServicesAccount.cs +++ b/src/CognitiveServices/CognitiveServices/CognitiveServicesAccount/SetAzureCognitiveServicesAccount.cs @@ -89,16 +89,16 @@ public override void ExecuteCmdlet() base.ExecuteCmdlet(); bool hasPropertiesChange = false; - var properties = new JObject(); + var properties = new CognitiveServicesAccountProperties(); if (!string.IsNullOrWhiteSpace(CustomSubdomainName)) { hasPropertiesChange = true; - properties["customSubDomainName"] = CustomSubdomainName; + properties.CustomSubDomainName = CustomSubdomainName; } if (NetworkRuleSet != null) { hasPropertiesChange = true; - properties["networkAcls"] = JToken.FromObject(NetworkRuleSet); + properties.NetworkAcls = NetworkRuleSet.ToNetworkRuleSet(); } Sku sku = null; @@ -152,9 +152,13 @@ public override void ExecuteCmdlet() var updatedAccount = this.CognitiveServicesClient.Accounts.Update( this.ResourceGroupName, this.Name, - sku, - tags, - properties); + new CognitiveServicesAccount() + { + Sku = sku, + Tags = tags, + Properties = properties + } + ); WriteCognitiveServicesAccount(updatedAccount); }); diff --git a/src/CognitiveServices/CognitiveServices/CognitiveServicesAccount/UpdateAzureCognitiveServicesAccountNetworkRuleSet.cs b/src/CognitiveServices/CognitiveServices/CognitiveServicesAccount/UpdateAzureCognitiveServicesAccountNetworkRuleSet.cs index 6f7cf68ae4c2..81c29440abd3 100644 --- a/src/CognitiveServices/CognitiveServices/CognitiveServicesAccount/UpdateAzureCognitiveServicesAccountNetworkRuleSet.cs +++ b/src/CognitiveServices/CognitiveServices/CognitiveServicesAccount/UpdateAzureCognitiveServicesAccountNetworkRuleSet.cs @@ -114,7 +114,7 @@ public override void ExecuteCmdlet() var account = this.CognitiveServicesClient.Accounts.GetProperties( this.ResourceGroupName, this.Name); - NetworkRuleSet accountACL = account.NetworkAcls; + NetworkRuleSet accountACL = account.Properties.NetworkAcls; if (accountACL == null) { @@ -138,13 +138,20 @@ public override void ExecuteCmdlet() psNetworkRule.DefaultAction = defaultAction.Value; } - var properties = new JObject(); - properties["networkAcls"] = JToken.FromObject(psNetworkRule.ToNetworkRuleSet()); - this.CognitiveServicesClient.Accounts.Update(this.ResourceGroupName, this.Name, null, null, properties); + var properties = new CognitiveServicesAccountProperties(); + properties.NetworkAcls = psNetworkRule.ToNetworkRuleSet(); + this.CognitiveServicesClient.Accounts.Update( + this.ResourceGroupName, + this.Name, + new CognitiveServicesAccount() + { + Properties = properties + } + ); account = this.CognitiveServicesClient.Accounts.GetProperties(this.ResourceGroupName, this.Name); - WriteObject(PSNetworkRuleSet.Create(account.NetworkAcls)); + WriteObject(PSNetworkRuleSet.Create(account.Properties.NetworkAcls)); } } } diff --git a/src/CognitiveServices/CognitiveServices/Models/PSCognitiveServicesAccount.cs b/src/CognitiveServices/CognitiveServices/Models/PSCognitiveServicesAccount.cs index 46fe4cb51034..26e5ba2a0bc6 100644 --- a/src/CognitiveServices/CognitiveServices/Models/PSCognitiveServicesAccount.cs +++ b/src/CognitiveServices/CognitiveServices/Models/PSCognitiveServicesAccount.cs @@ -27,19 +27,19 @@ public PSCognitiveServicesAccount(CognitiveServicesModels.CognitiveServicesAccou this.ResourceGroupName = ParseResourceGroupFromId(cognitiveServicesAccount.Id); this.AccountName = cognitiveServicesAccount.Name; this.Id = cognitiveServicesAccount.Id; - this.Endpoint = cognitiveServicesAccount.Endpoint; + this.Endpoint = cognitiveServicesAccount.Properties.Endpoint; this.Location = cognitiveServicesAccount.Location; this.Sku = cognitiveServicesAccount.Sku; this.AccountType = cognitiveServicesAccount.Kind; this.Etag = cognitiveServicesAccount.Etag; this.ResourceType = cognitiveServicesAccount.Type; - this.ProvisioningState = cognitiveServicesAccount.ProvisioningState; + this.ProvisioningState = cognitiveServicesAccount.Properties.ProvisioningState; this.Tags = cognitiveServicesAccount.Tags; - this.CustomSubDomainName = cognitiveServicesAccount.CustomSubDomainName; + this.CustomSubDomainName = cognitiveServicesAccount.Properties.CustomSubDomainName; - if (cognitiveServicesAccount.NetworkAcls != null) + if (cognitiveServicesAccount.Properties.NetworkAcls != null) { - this.NetworkRuleSet = PSNetworkRuleSet.Create(cognitiveServicesAccount.NetworkAcls); + this.NetworkRuleSet = PSNetworkRuleSet.Create(cognitiveServicesAccount.Properties.NetworkAcls); } }