Skip to content

Commit c65db81

Browse files
authored
Add 403 error for blob access in AzureVmssDeploymentV1 (#20770)
* Add 403 error for blob access in AzureVmssDeploymentV1 * updated task.loc.json
1 parent 39024db commit c65db81

File tree

12 files changed

+58
-24
lines changed

12 files changed

+58
-24
lines changed

Tasks/AzureVmssDeploymentV1/operations/VirtualMachineScaleSet.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,9 @@ export default class VirtualMachineScaleSet {
115115
customScriptInfo.storageAccount = await this._getStorageAccountDetails();
116116
customScriptInfo.blobUris = await this._uploadCustomScriptsToBlobService(customScriptInfo);
117117
} catch (error) {
118+
if (error.statusCode && error.statusCode == 403) {
119+
throw tl.loc("UploadingToStorageBlobsAuthenticationFailed", this.taskParameters.customScriptsStorageAccount );
120+
}
118121
throw tl.loc("UploadingToStorageBlobsFailed", error.message ? error.message : error);
119122
}
120123

@@ -264,6 +267,9 @@ export default class VirtualMachineScaleSet {
264267
return new Promise<void>((resolve, reject) => {
265268
client.virtualMachineExtensions.createOrUpdate(resourceGroupName, this.taskParameters.vmssName, azureModel.ComputeResourceType.VirtualMachineScaleSet, customScriptExtension.name, customScriptExtension, (error, result, request, response) => {
266269
if (error) {
270+
if (error.statusCode && error.statusCode == 403) {
271+
return reject(tl.loc("SettingVMExtensionFailedwithAuthentication", utils.getError(error) , this.taskParameters.vmssName));
272+
}
267273
return reject(tl.loc("SettingVMExtensionFailed", utils.getError(error)));
268274
}
269275

Tasks/AzureVmssDeploymentV1/task.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"author": "Microsoft Corporation",
1515
"version": {
1616
"Major": 1,
17-
"Minor": 249,
17+
"Minor": 251,
1818
"Patch": 0
1919
},
2020
"demands": [],
@@ -224,6 +224,8 @@
224224
"CouldNotFetchAccessTokenforAzureStatusCode": "Could not fetch access token for Azure. Status code: %s, status message: %s",
225225
"CouldNotFetchAccessTokenforMSIDueToMSINotConfiguredProperlyStatusCode": "Could not fetch access token for Managed Service Principal. Please configure Managed Service Identity (MSI) for virtual machine 'https://aka.ms/azure-msi-docs'. Status code: %s, status message: %s",
226226
"CouldNotFetchAccessTokenforMSIStatusCode": "Could not fetch access token for Managed Service Principal. Status code: %s, status message: %s",
227-
"ExpiredServicePrincipal": "Could not fetch access token for Azure. Verify if the Service Principal used is valid and not expired."
227+
"ExpiredServicePrincipal": "Could not fetch access token for Azure. Verify if the Service Principal used is valid and not expired.",
228+
"UploadingToStorageBlobsAuthenticationFailed": "Failed to upload custom scripts to azure blob storage. Please ensure that the subscription has the 'Storage Blob Data Contributor' role assigned for storage account '%s'.",
229+
"SettingVMExtensionFailedwithAuthentication": "Failed to install VM custom script extension on VMSS. Error: %s. Please ensure that the subscription has the 'Contributor' role assigned for vmss '%s'. "
228230
}
229231
}

Tasks/AzureVmssDeploymentV1/task.loc.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"author": "Microsoft Corporation",
1515
"version": {
1616
"Major": 1,
17-
"Minor": 249,
17+
"Minor": 251,
1818
"Patch": 0
1919
},
2020
"demands": [],
@@ -224,6 +224,8 @@
224224
"CouldNotFetchAccessTokenforAzureStatusCode": "ms-resource:loc.messages.CouldNotFetchAccessTokenforAzureStatusCode",
225225
"CouldNotFetchAccessTokenforMSIDueToMSINotConfiguredProperlyStatusCode": "ms-resource:loc.messages.CouldNotFetchAccessTokenforMSIDueToMSINotConfiguredProperlyStatusCode",
226226
"CouldNotFetchAccessTokenforMSIStatusCode": "ms-resource:loc.messages.CouldNotFetchAccessTokenforMSIStatusCode",
227-
"ExpiredServicePrincipal": "ms-resource:loc.messages.ExpiredServicePrincipal"
227+
"ExpiredServicePrincipal": "ms-resource:loc.messages.ExpiredServicePrincipal",
228+
"UploadingToStorageBlobsAuthenticationFailed": "ms-resource:loc.messages.UploadingToStorageBlobsAuthenticationFailed",
229+
"SettingVMExtensionFailedwithAuthentication": "ms-resource:loc.messages.SettingVMExtensionFailedwithAuthentication"
228230
}
229231
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Default|1.249.0
2-
Node20_229_6|1.249.1
1+
Default|1.251.0
2+
Node20_229_6|1.251.1

_generated/AzureVmssDeploymentV1/Strings/resources.resjson/en-US/resources.resjson

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,5 +76,7 @@
7676
"loc.messages.CouldNotFetchAccessTokenforAzureStatusCode": "Could not fetch access token for Azure. Status code: %s, status message: %s",
7777
"loc.messages.CouldNotFetchAccessTokenforMSIDueToMSINotConfiguredProperlyStatusCode": "Could not fetch access token for Managed Service Principal. Please configure Managed Service Identity (MSI) for virtual machine 'https://aka.ms/azure-msi-docs'. Status code: %s, status message: %s",
7878
"loc.messages.CouldNotFetchAccessTokenforMSIStatusCode": "Could not fetch access token for Managed Service Principal. Status code: %s, status message: %s",
79-
"loc.messages.ExpiredServicePrincipal": "Could not fetch access token for Azure. Verify if the Service Principal used is valid and not expired."
79+
"loc.messages.ExpiredServicePrincipal": "Could not fetch access token for Azure. Verify if the Service Principal used is valid and not expired.",
80+
"loc.messages.UploadingToStorageBlobsAuthenticationFailed": "Failed to upload custom scripts to azure blob storage. Please ensure that the subscription has the 'Storage Blob Data Contributor' role assigned for storage account '%s'.",
81+
"loc.messages.SettingVMExtensionFailedwithAuthentication": "Failed to install VM custom script extension on VMSS. Error: %s. Please ensure that the subscription has the 'Contributor' role assigned for vmss '%s'. "
8082
}

_generated/AzureVmssDeploymentV1/operations/VirtualMachineScaleSet.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,9 @@ export default class VirtualMachineScaleSet {
115115
customScriptInfo.storageAccount = await this._getStorageAccountDetails();
116116
customScriptInfo.blobUris = await this._uploadCustomScriptsToBlobService(customScriptInfo);
117117
} catch (error) {
118+
if (error.statusCode && error.statusCode == 403) {
119+
throw tl.loc("UploadingToStorageBlobsAuthenticationFailed", this.taskParameters.customScriptsStorageAccount );
120+
}
118121
throw tl.loc("UploadingToStorageBlobsFailed", error.message ? error.message : error);
119122
}
120123

@@ -264,6 +267,9 @@ export default class VirtualMachineScaleSet {
264267
return new Promise<void>((resolve, reject) => {
265268
client.virtualMachineExtensions.createOrUpdate(resourceGroupName, this.taskParameters.vmssName, azureModel.ComputeResourceType.VirtualMachineScaleSet, customScriptExtension.name, customScriptExtension, (error, result, request, response) => {
266269
if (error) {
270+
if (error.statusCode && error.statusCode == 403) {
271+
return reject(tl.loc("SettingVMExtensionFailedwithAuthentication", utils.getError(error) , this.taskParameters.vmssName));
272+
}
267273
return reject(tl.loc("SettingVMExtensionFailed", utils.getError(error)));
268274
}
269275

_generated/AzureVmssDeploymentV1/task.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"author": "Microsoft Corporation",
1515
"version": {
1616
"Major": 1,
17-
"Minor": 249,
17+
"Minor": 251,
1818
"Patch": 0
1919
},
2020
"demands": [],
@@ -224,10 +224,12 @@
224224
"CouldNotFetchAccessTokenforAzureStatusCode": "Could not fetch access token for Azure. Status code: %s, status message: %s",
225225
"CouldNotFetchAccessTokenforMSIDueToMSINotConfiguredProperlyStatusCode": "Could not fetch access token for Managed Service Principal. Please configure Managed Service Identity (MSI) for virtual machine 'https://aka.ms/azure-msi-docs'. Status code: %s, status message: %s",
226226
"CouldNotFetchAccessTokenforMSIStatusCode": "Could not fetch access token for Managed Service Principal. Status code: %s, status message: %s",
227-
"ExpiredServicePrincipal": "Could not fetch access token for Azure. Verify if the Service Principal used is valid and not expired."
227+
"ExpiredServicePrincipal": "Could not fetch access token for Azure. Verify if the Service Principal used is valid and not expired.",
228+
"UploadingToStorageBlobsAuthenticationFailed": "Failed to upload custom scripts to azure blob storage. Please ensure that the subscription has the 'Storage Blob Data Contributor' role assigned for storage account '%s'.",
229+
"SettingVMExtensionFailedwithAuthentication": "Failed to install VM custom script extension on VMSS. Error: %s. Please ensure that the subscription has the 'Contributor' role assigned for vmss '%s'. "
228230
},
229231
"_buildConfigMapping": {
230-
"Default": "1.249.0",
231-
"Node20_229_6": "1.249.1"
232+
"Default": "1.251.0",
233+
"Node20_229_6": "1.251.1"
232234
}
233235
}

_generated/AzureVmssDeploymentV1/task.loc.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"author": "Microsoft Corporation",
1515
"version": {
1616
"Major": 1,
17-
"Minor": 249,
17+
"Minor": 251,
1818
"Patch": 0
1919
},
2020
"demands": [],
@@ -224,10 +224,12 @@
224224
"CouldNotFetchAccessTokenforAzureStatusCode": "ms-resource:loc.messages.CouldNotFetchAccessTokenforAzureStatusCode",
225225
"CouldNotFetchAccessTokenforMSIDueToMSINotConfiguredProperlyStatusCode": "ms-resource:loc.messages.CouldNotFetchAccessTokenforMSIDueToMSINotConfiguredProperlyStatusCode",
226226
"CouldNotFetchAccessTokenforMSIStatusCode": "ms-resource:loc.messages.CouldNotFetchAccessTokenforMSIStatusCode",
227-
"ExpiredServicePrincipal": "ms-resource:loc.messages.ExpiredServicePrincipal"
227+
"ExpiredServicePrincipal": "ms-resource:loc.messages.ExpiredServicePrincipal",
228+
"UploadingToStorageBlobsAuthenticationFailed": "ms-resource:loc.messages.UploadingToStorageBlobsAuthenticationFailed",
229+
"SettingVMExtensionFailedwithAuthentication": "ms-resource:loc.messages.SettingVMExtensionFailedwithAuthentication"
228230
},
229231
"_buildConfigMapping": {
230-
"Default": "1.249.0",
231-
"Node20_229_6": "1.249.1"
232+
"Default": "1.251.0",
233+
"Node20_229_6": "1.251.1"
232234
}
233235
}

_generated/AzureVmssDeploymentV1_Node20/Strings/resources.resjson/en-US/resources.resjson

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,5 +76,7 @@
7676
"loc.messages.CouldNotFetchAccessTokenforAzureStatusCode": "Could not fetch access token for Azure. Status code: %s, status message: %s",
7777
"loc.messages.CouldNotFetchAccessTokenforMSIDueToMSINotConfiguredProperlyStatusCode": "Could not fetch access token for Managed Service Principal. Please configure Managed Service Identity (MSI) for virtual machine 'https://aka.ms/azure-msi-docs'. Status code: %s, status message: %s",
7878
"loc.messages.CouldNotFetchAccessTokenforMSIStatusCode": "Could not fetch access token for Managed Service Principal. Status code: %s, status message: %s",
79-
"loc.messages.ExpiredServicePrincipal": "Could not fetch access token for Azure. Verify if the Service Principal used is valid and not expired."
79+
"loc.messages.ExpiredServicePrincipal": "Could not fetch access token for Azure. Verify if the Service Principal used is valid and not expired.",
80+
"loc.messages.UploadingToStorageBlobsAuthenticationFailed": "Failed to upload custom scripts to azure blob storage. Please ensure that the subscription has the 'Storage Blob Data Contributor' role assigned for storage account '%s'.",
81+
"loc.messages.SettingVMExtensionFailedwithAuthentication": "Failed to install VM custom script extension on VMSS. Error: %s. Please ensure that the subscription has the 'Contributor' role assigned for vmss '%s'. "
8082
}

_generated/AzureVmssDeploymentV1_Node20/operations/VirtualMachineScaleSet.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,9 @@ export default class VirtualMachineScaleSet {
115115
customScriptInfo.storageAccount = await this._getStorageAccountDetails();
116116
customScriptInfo.blobUris = await this._uploadCustomScriptsToBlobService(customScriptInfo);
117117
} catch (error) {
118+
if (error.statusCode && error.statusCode == 403) {
119+
throw tl.loc("UploadingToStorageBlobsAuthenticationFailed", this.taskParameters.customScriptsStorageAccount );
120+
}
118121
throw tl.loc("UploadingToStorageBlobsFailed", error.message ? error.message : error);
119122
}
120123

@@ -264,6 +267,9 @@ export default class VirtualMachineScaleSet {
264267
return new Promise<void>((resolve, reject) => {
265268
client.virtualMachineExtensions.createOrUpdate(resourceGroupName, this.taskParameters.vmssName, azureModel.ComputeResourceType.VirtualMachineScaleSet, customScriptExtension.name, customScriptExtension, (error, result, request, response) => {
266269
if (error) {
270+
if (error.statusCode && error.statusCode == 403) {
271+
return reject(tl.loc("SettingVMExtensionFailedwithAuthentication", utils.getError(error) , this.taskParameters.vmssName));
272+
}
267273
return reject(tl.loc("SettingVMExtensionFailed", utils.getError(error)));
268274
}
269275

0 commit comments

Comments
 (0)