From 550acb9c881c01a3f37bf80dd10156442fe88c6c Mon Sep 17 00:00:00 2001 From: Yuwei Zhou Date: Fri, 12 Nov 2021 11:20:05 +0800 Subject: [PATCH 1/4] update Spring Cloud api version to 2020-07-01 --- .../Tests/DeploymentToStagingSucceedsL0.ts | 2 +- .../SetProductionNamedDeploymentSucceedsL0.ts | 2 +- .../SetProductionUseStagingSucceedsL0.ts | 2 +- .../azure-arm-spring-cloud.ts | 27 +++++++++++++++---- 4 files changed, 25 insertions(+), 8 deletions(-) diff --git a/Tasks/AzureSpringCloudV0/Tests/DeploymentToStagingSucceedsL0.ts b/Tasks/AzureSpringCloudV0/Tests/DeploymentToStagingSucceedsL0.ts index 12347cea545c..c89676671463 100644 --- a/Tasks/AzureSpringCloudV0/Tests/DeploymentToStagingSucceedsL0.ts +++ b/Tasks/AzureSpringCloudV0/Tests/DeploymentToStagingSucceedsL0.ts @@ -135,7 +135,7 @@ export class DeploymentFailsWithInsufficientDeploymentL0 { "user-agent": "TFS_useragent" } }) - .post(`/subscriptions/${MOCK_SUBSCRIPTION_ID}/resourceGroups/${MOCK_RESOURCE_GROUP_NAME}/providers/${ASC_RESOURCE_TYPE}/${this.TEST_NAME}/apps/${this.MOCK_APP_NAME}/getResourceUploadUrl?api-version=2019-05-01-preview`) + .post(`/subscriptions/${MOCK_SUBSCRIPTION_ID}/resourceGroups/${MOCK_RESOURCE_GROUP_NAME}/providers/${ASC_RESOURCE_TYPE}/${this.TEST_NAME}/apps/${this.MOCK_APP_NAME}/getResourceUploadUrl?api-version=2020-07-01`) .once() .reply(200, { diff --git a/Tasks/AzureSpringCloudV0/Tests/SetProductionNamedDeploymentSucceedsL0.ts b/Tasks/AzureSpringCloudV0/Tests/SetProductionNamedDeploymentSucceedsL0.ts index c204511a2b2c..3067579040d8 100644 --- a/Tasks/AzureSpringCloudV0/Tests/SetProductionNamedDeploymentSucceedsL0.ts +++ b/Tasks/AzureSpringCloudV0/Tests/SetProductionNamedDeploymentSucceedsL0.ts @@ -119,7 +119,7 @@ export class SetProductionNamedDeploymentSucceedsL0 { "content-type": "application/json; charset=utf-8", "user-agent": "TFS_useragent" } - }).patch(`/subscriptions/${MOCK_SUBSCRIPTION_ID}/resourceGroups/${encodeURIComponent(MOCK_RESOURCE_GROUP_NAME)}/providers/${ASC_RESOURCE_TYPE}/${this.TEST_NAME}/apps/${this.MOCK_APP_NAME}?api-version=2019-05-01-preview`) + }).patch(`/subscriptions/${MOCK_SUBSCRIPTION_ID}/resourceGroups/${encodeURIComponent(MOCK_RESOURCE_GROUP_NAME)}/providers/${ASC_RESOURCE_TYPE}/${this.TEST_NAME}/apps/${this.MOCK_APP_NAME}?api-version=2020-07-01`) .once() .reply((uri, serializedRequestBody)=>{ let requestBody = JSON.parse(serializedRequestBody); diff --git a/Tasks/AzureSpringCloudV0/Tests/SetProductionUseStagingSucceedsL0.ts b/Tasks/AzureSpringCloudV0/Tests/SetProductionUseStagingSucceedsL0.ts index a220a1fa7949..ebab8dd34864 100644 --- a/Tasks/AzureSpringCloudV0/Tests/SetProductionUseStagingSucceedsL0.ts +++ b/Tasks/AzureSpringCloudV0/Tests/SetProductionUseStagingSucceedsL0.ts @@ -119,7 +119,7 @@ export class SetProductionUseStagingSucceedsL0 { "content-type": "application/json; charset=utf-8", "user-agent": "TFS_useragent" } - }).patch(`/subscriptions/${MOCK_SUBSCRIPTION_ID}/resourceGroups/${encodeURIComponent(MOCK_RESOURCE_GROUP_NAME)}/providers/${ASC_RESOURCE_TYPE}/${this.TEST_NAME}/apps/${this.MOCK_APP_NAME}?api-version=2019-05-01-preview`) + }).patch(`/subscriptions/${MOCK_SUBSCRIPTION_ID}/resourceGroups/${encodeURIComponent(MOCK_RESOURCE_GROUP_NAME)}/providers/${ASC_RESOURCE_TYPE}/${this.TEST_NAME}/apps/${this.MOCK_APP_NAME}?api-version=2020-07-01`) .once() .reply((uri, serializedRequestBody)=>{ let requestBody = JSON.parse(serializedRequestBody); diff --git a/Tasks/AzureSpringCloudV0/deploymentProvider/azure-arm-spring-cloud.ts b/Tasks/AzureSpringCloudV0/deploymentProvider/azure-arm-spring-cloud.ts index 7382b8084a28..afdbf61225b9 100644 --- a/Tasks/AzureSpringCloudV0/deploymentProvider/azure-arm-spring-cloud.ts +++ b/Tasks/AzureSpringCloudV0/deploymentProvider/azure-arm-spring-cloud.ts @@ -98,7 +98,7 @@ export class AzureSpringCloud { const requestUri = this._client.getRequestUri(`${this._resourceId}/apps/{appName}`, { '{appName}': appName, '{deploymentName}': deploymentName - }, null, '2019-05-01-preview'); + }, null, '2020-07-01'); const requestBody = JSON.stringify( { properties: { @@ -112,10 +112,27 @@ export class AzureSpringCloud { console.log('Response:'); console.log(response.body); - if (response.statusCode != 200) { - console.error('Error code: ' + response.statusCode); - console.error(response.statusMessage); + let expectedStatusCodes: number[] = [200, 202]; + if (!expectedStatusCodes.includes(response.statusCode)) { + tl.error('Error code: ' + response.statusCode); + tl.error(response.statusMessage); throw Error(response.statusCode + ":" + response.statusMessage); + } else { + tl.debug('App update initiated.') + //If the operation is asynchronous, block pending its conclusion. + var operationStatusUrl = response.headers[ASYNC_OPERATION_HEADER]; + if (operationStatusUrl) { + tl.debug('Awaiting operation completion.'); + try { + await this.awaitOperationCompletion(operationStatusUrl); + } catch (error) { + tl.debug('Error in awaiting operation completion'); + throw error; + } + } else { + tl.debug('Received async status code with no async operation. Headers: '); + tl.debug(JSON.stringify(response.headers)); + } } } @@ -170,7 +187,7 @@ export class AzureSpringCloud { const requestUri = this._client.getRequestUri(`${this._resourceId}/apps/{appName}/getResourceUploadUrl`, { '{appName}': appName - }, null, '2019-05-01-preview'); + }, null, '2020-07-01'); const response = await this.sendRequest('POST', requestUri, null); From a7d3fa801e1aac5a98181ae56a0c0a8db386c511 Mon Sep 17 00:00:00 2001 From: Yuwei Zhou Date: Fri, 12 Nov 2021 11:25:59 +0800 Subject: [PATCH 2/4] update-version --- Tasks/AzureSpringCloudV0/task.json | 4 ++-- Tasks/AzureSpringCloudV0/task.loc.json | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Tasks/AzureSpringCloudV0/task.json b/Tasks/AzureSpringCloudV0/task.json index 5923f99cfac8..5f22bbb72cc8 100644 --- a/Tasks/AzureSpringCloudV0/task.json +++ b/Tasks/AzureSpringCloudV0/task.json @@ -12,8 +12,8 @@ "preview": true, "version": { "Major": 0, - "Minor": 185, - "Patch": 6 + "Minor": 196, + "Patch": 0 }, "minimumAgentVersion": "2.104.1", "groups": [ diff --git a/Tasks/AzureSpringCloudV0/task.loc.json b/Tasks/AzureSpringCloudV0/task.loc.json index b48c88f393e7..eac2dccdb902 100644 --- a/Tasks/AzureSpringCloudV0/task.loc.json +++ b/Tasks/AzureSpringCloudV0/task.loc.json @@ -18,8 +18,8 @@ "preview": true, "version": { "Major": 0, - "Minor": 185, - "Patch": 5 + "Minor": 196, + "Patch": 0 }, "minimumAgentVersion": "2.104.1", "groups": [ From 670e4fddd6e9e044c0156055b984a09ccd6c994a Mon Sep 17 00:00:00 2001 From: Yuwei Zhou Date: Thu, 23 Dec 2021 13:17:21 +0800 Subject: [PATCH 3/4] Update version --- Tasks/AzureSpringCloudV0/task.loc.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tasks/AzureSpringCloudV0/task.loc.json b/Tasks/AzureSpringCloudV0/task.loc.json index eac2dccdb902..80129a1b1847 100644 --- a/Tasks/AzureSpringCloudV0/task.loc.json +++ b/Tasks/AzureSpringCloudV0/task.loc.json @@ -18,7 +18,7 @@ "preview": true, "version": { "Major": 0, - "Minor": 196, + "Minor": 198, "Patch": 0 }, "minimumAgentVersion": "2.104.1", @@ -235,4 +235,4 @@ "Nopackagefoundwithspecifiedpattern": "ms-resource:loc.messages.Nopackagefoundwithspecifiedpattern", "MorethanonepackagematchedwithspecifiedpatternPleaserestrainthesearchpattern": "ms-resource:loc.messages.MorethanonepackagematchedwithspecifiedpatternPleaserestrainthesearchpattern" } -} \ No newline at end of file +} From 3838737f4d778eb1d72db8907823045a6fe03a03 Mon Sep 17 00:00:00 2001 From: Yuwei Zhou Date: Thu, 23 Dec 2021 13:20:08 +0800 Subject: [PATCH 4/4] Update task.json --- Tasks/AzureSpringCloudV0/task.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tasks/AzureSpringCloudV0/task.json b/Tasks/AzureSpringCloudV0/task.json index 5f22bbb72cc8..f36a3e20ad7b 100644 --- a/Tasks/AzureSpringCloudV0/task.json +++ b/Tasks/AzureSpringCloudV0/task.json @@ -12,7 +12,7 @@ "preview": true, "version": { "Major": 0, - "Minor": 196, + "Minor": 198, "Patch": 0 }, "minimumAgentVersion": "2.104.1",