Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add 403 error for blob access in AzureVmssDeploymentV1 #20770

Merged
merged 5 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ export default class VirtualMachineScaleSet {
customScriptInfo.storageAccount = await this._getStorageAccountDetails();
customScriptInfo.blobUris = await this._uploadCustomScriptsToBlobService(customScriptInfo);
} catch (error) {
if (error.statusCode && error.statusCode == 403) {
throw tl.loc("UploadingToStorageBlobsAuthenticationFailed", this.taskParameters.customScriptsStorageAccount );
}
throw tl.loc("UploadingToStorageBlobsFailed", error.message ? error.message : error);
}

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

Expand Down
6 changes: 4 additions & 2 deletions Tasks/AzureVmssDeploymentV1/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"author": "Microsoft Corporation",
"version": {
"Major": 1,
"Minor": 249,
"Minor": 251,
"Patch": 0
},
"demands": [],
Expand Down Expand Up @@ -224,6 +224,8 @@
"CouldNotFetchAccessTokenforAzureStatusCode": "Could not fetch access token for Azure. Status code: %s, status message: %s",
"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",
"CouldNotFetchAccessTokenforMSIStatusCode": "Could not fetch access token for Managed Service Principal. Status code: %s, status message: %s",
"ExpiredServicePrincipal": "Could not fetch access token for Azure. Verify if the Service Principal used is valid and not expired."
"ExpiredServicePrincipal": "Could not fetch access token for Azure. Verify if the Service Principal used is valid and not expired.",
"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'.",
"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'. "
}
}
6 changes: 4 additions & 2 deletions Tasks/AzureVmssDeploymentV1/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"author": "Microsoft Corporation",
"version": {
"Major": 1,
"Minor": 249,
"Minor": 251,
"Patch": 0
},
"demands": [],
Expand Down Expand Up @@ -224,6 +224,8 @@
"CouldNotFetchAccessTokenforAzureStatusCode": "ms-resource:loc.messages.CouldNotFetchAccessTokenforAzureStatusCode",
"CouldNotFetchAccessTokenforMSIDueToMSINotConfiguredProperlyStatusCode": "ms-resource:loc.messages.CouldNotFetchAccessTokenforMSIDueToMSINotConfiguredProperlyStatusCode",
"CouldNotFetchAccessTokenforMSIStatusCode": "ms-resource:loc.messages.CouldNotFetchAccessTokenforMSIStatusCode",
"ExpiredServicePrincipal": "ms-resource:loc.messages.ExpiredServicePrincipal"
"ExpiredServicePrincipal": "ms-resource:loc.messages.ExpiredServicePrincipal",
"UploadingToStorageBlobsAuthenticationFailed": "ms-resource:loc.messages.UploadingToStorageBlobsAuthenticationFailed",
"SettingVMExtensionFailedwithAuthentication": "ms-resource:loc.messages.SettingVMExtensionFailedwithAuthentication"
}
}
4 changes: 2 additions & 2 deletions _generated/AzureVmssDeploymentV1.versionmap.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Default|1.249.0
Node20_229_6|1.249.1
Default|1.251.0
Node20_229_6|1.251.1
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,7 @@
"loc.messages.CouldNotFetchAccessTokenforAzureStatusCode": "Could not fetch access token for Azure. Status code: %s, status message: %s",
"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",
"loc.messages.CouldNotFetchAccessTokenforMSIStatusCode": "Could not fetch access token for Managed Service Principal. Status code: %s, status message: %s",
"loc.messages.ExpiredServicePrincipal": "Could not fetch access token for Azure. Verify if the Service Principal used is valid and not expired."
"loc.messages.ExpiredServicePrincipal": "Could not fetch access token for Azure. Verify if the Service Principal used is valid and not expired.",
"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'.",
"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'. "
}
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ export default class VirtualMachineScaleSet {
customScriptInfo.storageAccount = await this._getStorageAccountDetails();
customScriptInfo.blobUris = await this._uploadCustomScriptsToBlobService(customScriptInfo);
} catch (error) {
if (error.statusCode && error.statusCode == 403) {
throw tl.loc("UploadingToStorageBlobsAuthenticationFailed", this.taskParameters.customScriptsStorageAccount );
}
throw tl.loc("UploadingToStorageBlobsFailed", error.message ? error.message : error);
}

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

Expand Down
10 changes: 6 additions & 4 deletions _generated/AzureVmssDeploymentV1/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"author": "Microsoft Corporation",
"version": {
"Major": 1,
"Minor": 249,
"Minor": 251,
"Patch": 0
},
"demands": [],
Expand Down Expand Up @@ -224,10 +224,12 @@
"CouldNotFetchAccessTokenforAzureStatusCode": "Could not fetch access token for Azure. Status code: %s, status message: %s",
"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",
"CouldNotFetchAccessTokenforMSIStatusCode": "Could not fetch access token for Managed Service Principal. Status code: %s, status message: %s",
"ExpiredServicePrincipal": "Could not fetch access token for Azure. Verify if the Service Principal used is valid and not expired."
"ExpiredServicePrincipal": "Could not fetch access token for Azure. Verify if the Service Principal used is valid and not expired.",
"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'.",
"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'. "
},
"_buildConfigMapping": {
"Default": "1.249.0",
"Node20_229_6": "1.249.1"
"Default": "1.251.0",
"Node20_229_6": "1.251.1"
}
}
10 changes: 6 additions & 4 deletions _generated/AzureVmssDeploymentV1/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"author": "Microsoft Corporation",
"version": {
"Major": 1,
"Minor": 249,
"Minor": 251,
"Patch": 0
},
"demands": [],
Expand Down Expand Up @@ -224,10 +224,12 @@
"CouldNotFetchAccessTokenforAzureStatusCode": "ms-resource:loc.messages.CouldNotFetchAccessTokenforAzureStatusCode",
"CouldNotFetchAccessTokenforMSIDueToMSINotConfiguredProperlyStatusCode": "ms-resource:loc.messages.CouldNotFetchAccessTokenforMSIDueToMSINotConfiguredProperlyStatusCode",
"CouldNotFetchAccessTokenforMSIStatusCode": "ms-resource:loc.messages.CouldNotFetchAccessTokenforMSIStatusCode",
"ExpiredServicePrincipal": "ms-resource:loc.messages.ExpiredServicePrincipal"
"ExpiredServicePrincipal": "ms-resource:loc.messages.ExpiredServicePrincipal",
"UploadingToStorageBlobsAuthenticationFailed": "ms-resource:loc.messages.UploadingToStorageBlobsAuthenticationFailed",
"SettingVMExtensionFailedwithAuthentication": "ms-resource:loc.messages.SettingVMExtensionFailedwithAuthentication"
},
"_buildConfigMapping": {
"Default": "1.249.0",
"Node20_229_6": "1.249.1"
"Default": "1.251.0",
"Node20_229_6": "1.251.1"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,7 @@
"loc.messages.CouldNotFetchAccessTokenforAzureStatusCode": "Could not fetch access token for Azure. Status code: %s, status message: %s",
"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",
"loc.messages.CouldNotFetchAccessTokenforMSIStatusCode": "Could not fetch access token for Managed Service Principal. Status code: %s, status message: %s",
"loc.messages.ExpiredServicePrincipal": "Could not fetch access token for Azure. Verify if the Service Principal used is valid and not expired."
"loc.messages.ExpiredServicePrincipal": "Could not fetch access token for Azure. Verify if the Service Principal used is valid and not expired.",
"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'.",
"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'. "
}
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ export default class VirtualMachineScaleSet {
customScriptInfo.storageAccount = await this._getStorageAccountDetails();
customScriptInfo.blobUris = await this._uploadCustomScriptsToBlobService(customScriptInfo);
} catch (error) {
if (error.statusCode && error.statusCode == 403) {
throw tl.loc("UploadingToStorageBlobsAuthenticationFailed", this.taskParameters.customScriptsStorageAccount );
}
throw tl.loc("UploadingToStorageBlobsFailed", error.message ? error.message : error);
}

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

Expand Down
10 changes: 6 additions & 4 deletions _generated/AzureVmssDeploymentV1_Node20/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"author": "Microsoft Corporation",
"version": {
"Major": 1,
"Minor": 249,
"Minor": 251,
"Patch": 1
},
"demands": [],
Expand Down Expand Up @@ -224,10 +224,12 @@
"CouldNotFetchAccessTokenforAzureStatusCode": "Could not fetch access token for Azure. Status code: %s, status message: %s",
"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",
"CouldNotFetchAccessTokenforMSIStatusCode": "Could not fetch access token for Managed Service Principal. Status code: %s, status message: %s",
"ExpiredServicePrincipal": "Could not fetch access token for Azure. Verify if the Service Principal used is valid and not expired."
"ExpiredServicePrincipal": "Could not fetch access token for Azure. Verify if the Service Principal used is valid and not expired.",
"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'.",
"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'. "
},
"_buildConfigMapping": {
"Default": "1.249.0",
"Node20_229_6": "1.249.1"
"Default": "1.251.0",
"Node20_229_6": "1.251.1"
}
}
10 changes: 6 additions & 4 deletions _generated/AzureVmssDeploymentV1_Node20/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"author": "Microsoft Corporation",
"version": {
"Major": 1,
"Minor": 249,
"Minor": 251,
"Patch": 1
},
"demands": [],
Expand Down Expand Up @@ -224,10 +224,12 @@
"CouldNotFetchAccessTokenforAzureStatusCode": "ms-resource:loc.messages.CouldNotFetchAccessTokenforAzureStatusCode",
"CouldNotFetchAccessTokenforMSIDueToMSINotConfiguredProperlyStatusCode": "ms-resource:loc.messages.CouldNotFetchAccessTokenforMSIDueToMSINotConfiguredProperlyStatusCode",
"CouldNotFetchAccessTokenforMSIStatusCode": "ms-resource:loc.messages.CouldNotFetchAccessTokenforMSIStatusCode",
"ExpiredServicePrincipal": "ms-resource:loc.messages.ExpiredServicePrincipal"
"ExpiredServicePrincipal": "ms-resource:loc.messages.ExpiredServicePrincipal",
"UploadingToStorageBlobsAuthenticationFailed": "ms-resource:loc.messages.UploadingToStorageBlobsAuthenticationFailed",
"SettingVMExtensionFailedwithAuthentication": "ms-resource:loc.messages.SettingVMExtensionFailedwithAuthentication"
},
"_buildConfigMapping": {
"Default": "1.249.0",
"Node20_229_6": "1.249.1"
"Default": "1.251.0",
"Node20_229_6": "1.251.1"
}
}