{"action":"created","comment":{"url":"https://api.github.com/repos/Microsoft/vsts-tasks/pulls/comments/124482763","pull_request_review_id":46773187,"id":124482763,"diff_hunk":"@@ -61,22 +42,120 @@ export default class VirtualMachineScaleSet {\n                                     \"commandToExecute\": this.taskParameters.customScriptCommand\n                                 }\n                             }\n-                        }\n+                        };\n+\n+                        this._getExistingCustomScriptExtension(client, resourceGroupName, customScriptExtension, (error, matchingExtension, request, response) => {\n+                            // if extension already exists, remove it\n+                            if(!!matchingExtension) {\n+                                this._deleteAndInstallCustomScriptExtension(client, resourceGroupName, matchingExtension, customScriptExtension, resolve, reject, (error, matchingExtension, request, response) => {\n+                                    this._updateImageInternal(client, resourceGroupName, resolve, reject);\n+                                });\n+                            } else {\n+                                this._installCustomScripExtension(client, resourceGroupName, customScriptExtension, resolve, reject, (error, result, request, response) => {\n+                                    this._updateImageInternal(client, resourceGroupName, resolve, reject);\n+                                });\n+                            }\n+                        });\n+                    } else {\n+                        this._updateImageInternal(client, resourceGroupName, resolve, reject);\n                     }\n \n-                    client.virtualMachineScaleSets.updateImage(resourceGroupName, this.taskParameters.vmssName, this.taskParameters.imageUrl, customScriptExtension, null, (error, result, request, response) => {\n-                        if (error) {\n-                            return reject(tl.loc(\"VMSSImageUpdateFailed\", utils.getError(error)));\n-                        }\n-                        console.log(tl.loc(\"UpdatedVMSSImage\"));\n-                        return resolve();\n-                    });\n                     break;\n                 }\n             });\n         });\n     }\n \n+    private _getResourceGroupForVmss(client, resolve, reject, callback): void {","path":"Tasks/AzureVmssDeployment/operations/VirtualMachineScaleSet.ts","position":68,"original_position":68,"commit_id":"cb9b4511f9f05db29b693ac3a60cb895c1ab8d48","original_commit_id":"f3f630f92492ee9548f61e434f6371b25f8afc0d","user":{"login":"sachinma","id":17923727,"avatar_url":"https://avatars1.githubusercontent.com/u/17923727?v=3","gravatar_id":"","url":"https://api.github.com/users/sachinma","html_url":"https://github.com/sachinma","followers_url":"https://api.github.com/users/sachinma/followers","following_url":"https://api.github.com/users/sachinma/following{/other_user}","gists_url":"https://api.github.com/users/sachinma/gists{/gist_id}","starred_url":"https://api.github.com/users/sachinma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sachinma/subscriptions","organizations_url":"https://api.github.com/users/sachinma/orgs","repos_url":"https://api.github.com/users/sachinma/repos","events_url":"https://api.github.com/users/sachinma/events{/privacy}","received_events_url":"https://api.github.com/users/sachinma/received_events","type":"User","site_admin":false},"body":"You are right; however I think that will improve the code readability. For example your main method will not have nested statements and be more readable and less error-prone like following.\r\nvar resourceGroupDetails = await this.getResourceGroupName;\r\nvar extensionStatus = await this.getExistingExtensions();","created_at":"2017-06-28T08:37:19Z","updated_at":"2017-06-28T08:37:43Z","html_url":"https://github.com/Microsoft/vsts-tasks/pull/4645#discussion_r124482763","pull_request_url":"https://api.github.com/repos/Microsoft/vsts-tasks/pulls/4645","_links":{"self":{"href":"https://api.github.com/repos/Microsoft/vsts-tasks/pulls/comments/124482763"},"html":{"href":"https://github.com/Microsoft/vsts-tasks/pull/4645#discussion_r124482763"},"pull_request":{"href":"https://api.github.com/repos/Microsoft/vsts-tasks/pulls/4645"}}},"pull_request":{"url":"https://api.github.com/repos/Microsoft/vsts-tasks/pulls/4645","id":127631406,"html_url":"https://github.com/Microsoft/vsts-tasks/pull/4645","diff_url":"https://github.com/Microsoft/vsts-tasks/pull/4645.diff","patch_url":"https://github.com/Microsoft/vsts-tasks/pull/4645.patch","issue_url":"https://api.github.com/repos/Microsoft/vsts-tasks/issues/4645","number":4645,"state":"open","locked":false,"title":"Enabling custom script extension support for VMSS deployment","user":{"login":"bishal-pdMSFT","id":7830141,"avatar_url":"https://avatars0.githubusercontent.com/u/7830141?v=3","gravatar_id":"","url":"https://api.github.com/users/bishal-pdMSFT","html_url":"https://github.com/bishal-pdMSFT","followers_url":"https://api.github.com/users/bishal-pdMSFT/followers","following_url":"https://api.github.com/users/bishal-pdMSFT/following{/other_user}","gists_url":"https://api.github.com/users/bishal-pdMSFT/gists{/gist_id}","starred_url":"https://api.github.com/users/bishal-pdMSFT/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bishal-pdMSFT/subscriptions","organizations_url":"https://api.github.com/users/bishal-pdMSFT/orgs","repos_url":"https://api.github.com/users/bishal-pdMSFT/repos","events_url":"https://api.github.com/users/bishal-pdMSFT/events{/privacy}","received_events_url":"https://api.github.com/users/bishal-pdMSFT/received_events","type":"User","site_admin":false},"body":"Setting extension is done separately from updating image(earlier it was part of same PATCH call). Flow is:\r\n1. List VM extensions for VMSS\r\n2. Check if custom script extension exists\r\n3. If so, delete existing extension\r\n4. Install extension\r\n5. Update VMSS image ","created_at":"2017-06-27T07:51:43Z","updated_at":"2017-06-28T08:37:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2cfcf344e3a2925d969094198a4d1772337880f1","assignee":null,"assignees":[],"requested_reviewers":[{"login":"ds-ms","id":25762922,"avatar_url":"https://avatars0.githubusercontent.com/u/25762922?v=3","gravatar_id":"","url":"https://api.github.com/users/ds-ms","html_url":"https://github.com/ds-ms","followers_url":"https://api.github.com/users/ds-ms/followers","following_url":"https://api.github.com/users/ds-ms/following{/other_user}","gists_url":"https://api.github.com/users/ds-ms/gists{/gist_id}","starred_url":"https://api.github.com/users/ds-ms/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ds-ms/subscriptions","organizations_url":"https://api.github.com/users/ds-ms/orgs","repos_url":"https://api.github.com/users/ds-ms/repos","events_url":"https://api.github.com/users/ds-ms/events{/privacy}","received_events_url":"https://api.github.com/users/ds-ms/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/Microsoft/vsts-tasks/pulls/4645/commits","review_comments_url":"https://api.github.com/repos/Microsoft/vsts-tasks/pulls/4645/comments","review_comment_url":"https://api.github.com/repos/Microsoft/vsts-tasks/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Microsoft/vsts-tasks/issues/4645/comments","statuses_url":"https://api.github.com/repos/Microsoft/vsts-tasks/statuses/cb9b4511f9f05db29b693ac3a60cb895c1ab8d48","head":{"label":"Microsoft:users/biprasad/VmssExtension","ref":"users/biprasad/VmssExtension","sha":"cb9b4511f9f05db29b693ac3a60cb895c1ab8d48","user":{"login":"Microsoft","id":6154722,"avatar_url":"https://avatars1.githubusercontent.com/u/6154722?v=3","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"repo":{"id":27631673,"name":"vsts-tasks","full_name":"Microsoft/vsts-tasks","owner":{"login":"Microsoft","id":6154722,"avatar_url":"https://avatars1.githubusercontent.com/u/6154722?v=3","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Microsoft/vsts-tasks","description":"Build and Release Tasks for Visual Studio Team Services and Team Foundation Server","fork":false,"url":"https://api.github.com/repos/Microsoft/vsts-tasks","forks_url":"https://api.github.com/repos/Microsoft/vsts-tasks/forks","keys_url":"https://api.github.com/repos/Microsoft/vsts-tasks/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Microsoft/vsts-tasks/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Microsoft/vsts-tasks/teams","hooks_url":"https://api.github.com/repos/Microsoft/vsts-tasks/hooks","issue_events_url":"https://api.github.com/repos/Microsoft/vsts-tasks/issues/events{/number}","events_url":"https://api.github.com/repos/Microsoft/vsts-tasks/events","assignees_url":"https://api.github.com/repos/Microsoft/vsts-tasks/assignees{/user}","branches_url":"https://api.github.com/repos/Microsoft/vsts-tasks/branches{/branch}","tags_url":"https://api.github.com/repos/Microsoft/vsts-tasks/tags","blobs_url":"https://api.github.com/repos/Microsoft/vsts-tasks/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Microsoft/vsts-tasks/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Microsoft/vsts-tasks/git/refs{/sha}","trees_url":"https://api.github.com/repos/Microsoft/vsts-tasks/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Microsoft/vsts-tasks/statuses/{sha}","languages_url":"https://api.github.com/repos/Microsoft/vsts-tasks/languages","stargazers_url":"https://api.github.com/repos/Microsoft/vsts-tasks/stargazers","contributors_url":"https://api.github.com/repos/Microsoft/vsts-tasks/contributors","subscribers_url":"https://api.github.com/repos/Microsoft/vsts-tasks/subscribers","subscription_url":"https://api.github.com/repos/Microsoft/vsts-tasks/subscription","commits_url":"https://api.github.com/repos/Microsoft/vsts-tasks/commits{/sha}","git_commits_url":"https://api.github.com/repos/Microsoft/vsts-tasks/git/commits{/sha}","comments_url":"https://api.github.com/repos/Microsoft/vsts-tasks/comments{/number}","issue_comment_url":"https://api.github.com/repos/Microsoft/vsts-tasks/issues/comments{/number}","contents_url":"https://api.github.com/repos/Microsoft/vsts-tasks/contents/{+path}","compare_url":"https://api.github.com/repos/Microsoft/vsts-tasks/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Microsoft/vsts-tasks/merges","archive_url":"https://api.github.com/repos/Microsoft/vsts-tasks/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Microsoft/vsts-tasks/downloads","issues_url":"https://api.github.com/repos/Microsoft/vsts-tasks/issues{/number}","pulls_url":"https://api.github.com/repos/Microsoft/vsts-tasks/pulls{/number}","milestones_url":"https://api.github.com/repos/Microsoft/vsts-tasks/milestones{/number}","notifications_url":"https://api.github.com/repos/Microsoft/vsts-tasks/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Microsoft/vsts-tasks/labels{/name}","releases_url":"https://api.github.com/repos/Microsoft/vsts-tasks/releases{/id}","deployments_url":"https://api.github.com/repos/Microsoft/vsts-tasks/deployments","created_at":"2014-12-06T11:11:46Z","updated_at":"2017-06-28T06:26:33Z","pushed_at":"2017-06-28T08:10:28Z","git_url":"git://github.com/Microsoft/vsts-tasks.git","ssh_url":"git@github.com:Microsoft/vsts-tasks.git","clone_url":"https://github.com/Microsoft/vsts-tasks.git","svn_url":"https://github.com/Microsoft/vsts-tasks","homepage":"https://aka.ms/tfbuild","size":31823,"stargazers_count":610,"watchers_count":610,"language":"TypeScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":552,"mirror_url":null,"open_issues_count":167,"forks":552,"open_issues":167,"watchers":610,"default_branch":"master"}},"base":{"label":"Microsoft:master","ref":"master","sha":"bce408c2846d9274c8da4f1216909024252d5f37","user":{"login":"Microsoft","id":6154722,"avatar_url":"https://avatars1.githubusercontent.com/u/6154722?v=3","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"repo":{"id":27631673,"name":"vsts-tasks","full_name":"Microsoft/vsts-tasks","owner":{"login":"Microsoft","id":6154722,"avatar_url":"https://avatars1.githubusercontent.com/u/6154722?v=3","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Microsoft/vsts-tasks","description":"Build and Release Tasks for Visual Studio Team Services and Team Foundation Server","fork":false,"url":"https://api.github.com/repos/Microsoft/vsts-tasks","forks_url":"https://api.github.com/repos/Microsoft/vsts-tasks/forks","keys_url":"https://api.github.com/repos/Microsoft/vsts-tasks/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Microsoft/vsts-tasks/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Microsoft/vsts-tasks/teams","hooks_url":"https://api.github.com/repos/Microsoft/vsts-tasks/hooks","issue_events_url":"https://api.github.com/repos/Microsoft/vsts-tasks/issues/events{/number}","events_url":"https://api.github.com/repos/Microsoft/vsts-tasks/events","assignees_url":"https://api.github.com/repos/Microsoft/vsts-tasks/assignees{/user}","branches_url":"https://api.github.com/repos/Microsoft/vsts-tasks/branches{/branch}","tags_url":"https://api.github.com/repos/Microsoft/vsts-tasks/tags","blobs_url":"https://api.github.com/repos/Microsoft/vsts-tasks/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Microsoft/vsts-tasks/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Microsoft/vsts-tasks/git/refs{/sha}","trees_url":"https://api.github.com/repos/Microsoft/vsts-tasks/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Microsoft/vsts-tasks/statuses/{sha}","languages_url":"https://api.github.com/repos/Microsoft/vsts-tasks/languages","stargazers_url":"https://api.github.com/repos/Microsoft/vsts-tasks/stargazers","contributors_url":"https://api.github.com/repos/Microsoft/vsts-tasks/contributors","subscribers_url":"https://api.github.com/repos/Microsoft/vsts-tasks/subscribers","subscription_url":"https://api.github.com/repos/Microsoft/vsts-tasks/subscription","commits_url":"https://api.github.com/repos/Microsoft/vsts-tasks/commits{/sha}","git_commits_url":"https://api.github.com/repos/Microsoft/vsts-tasks/git/commits{/sha}","comments_url":"https://api.github.com/repos/Microsoft/vsts-tasks/comments{/number}","issue_comment_url":"https://api.github.com/repos/Microsoft/vsts-tasks/issues/comments{/number}","contents_url":"https://api.github.com/repos/Microsoft/vsts-tasks/contents/{+path}","compare_url":"https://api.github.com/repos/Microsoft/vsts-tasks/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Microsoft/vsts-tasks/merges","archive_url":"https://api.github.com/repos/Microsoft/vsts-tasks/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Microsoft/vsts-tasks/downloads","issues_url":"https://api.github.com/repos/Microsoft/vsts-tasks/issues{/number}","pulls_url":"https://api.github.com/repos/Microsoft/vsts-tasks/pulls{/number}","milestones_url":"https://api.github.com/repos/Microsoft/vsts-tasks/milestones{/number}","notifications_url":"https://api.github.com/repos/Microsoft/vsts-tasks/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Microsoft/vsts-tasks/labels{/name}","releases_url":"https://api.github.com/repos/Microsoft/vsts-tasks/releases{/id}","deployments_url":"https://api.github.com/repos/Microsoft/vsts-tasks/deployments","created_at":"2014-12-06T11:11:46Z","updated_at":"2017-06-28T06:26:33Z","pushed_at":"2017-06-28T08:10:28Z","git_url":"git://github.com/Microsoft/vsts-tasks.git","ssh_url":"git@github.com:Microsoft/vsts-tasks.git","clone_url":"https://github.com/Microsoft/vsts-tasks.git","svn_url":"https://github.com/Microsoft/vsts-tasks","homepage":"https://aka.ms/tfbuild","size":31823,"stargazers_count":610,"watchers_count":610,"language":"TypeScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":552,"mirror_url":null,"open_issues_count":167,"forks":552,"open_issues":167,"watchers":610,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Microsoft/vsts-tasks/pulls/4645"},"html":{"href":"https://github.com/Microsoft/vsts-tasks/pull/4645"},"issue":{"href":"https://api.github.com/repos/Microsoft/vsts-tasks/issues/4645"},"comments":{"href":"https://api.github.com/repos/Microsoft/vsts-tasks/issues/4645/comments"},"review_comments":{"href":"https://api.github.com/repos/Microsoft/vsts-tasks/pulls/4645/comments"},"review_comment":{"href":"https://api.github.com/repos/Microsoft/vsts-tasks/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Microsoft/vsts-tasks/pulls/4645/commits"},"statuses":{"href":"https://api.github.com/repos/Microsoft/vsts-tasks/statuses/cb9b4511f9f05db29b693ac3a60cb895c1ab8d48"}}}}
{"actor":{"display_login":"sachinma"}}