Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into Localization
Browse files Browse the repository at this point in the history
  • Loading branch information
vmapetr committed Feb 1, 2024
2 parents 9ea15ce + 631cd0d commit d6fe135
Show file tree
Hide file tree
Showing 247 changed files with 17,451 additions and 1,225 deletions.
200 changes: 101 additions & 99 deletions .github/CODEOWNERS

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@
"loc.messages.FoundMultipleFiles": "Found multiple files matching %s.",
"loc.messages.FailedToCreateFile": "Failed to create %s with error: %s.",
"loc.messages.FailedToFindFile": "Failed to find %s at %s.",
"loc.messages.DeprecatedTask": "The AppCenterDistribute@1 (App Center distribute) task has been deprecated since November 14, 2022 and will soon be retired. Use the AppCenterDistribute@3 task instead."
"loc.messages.DeprecatedTask": "The AppCenterDistribute@1 (App Center distribute) task has been deprecated since November 14, 2022 and will soon be retired. Use the AppCenterDistribute@3 task instead. Please visit https://aka.ms/azdo-deprecated-tasks to learn more about deprecated tasks."
}
4 changes: 2 additions & 2 deletions Tasks/AppCenterDistributeV1/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"version": {
"Major": 1,
"Minor": 235,
"Patch": 0
"Patch": 2
},
"minimumAgentVersion": "2.144.0",
"releaseNotes": "Fix bug where feature branches were being truncated.",
Expand Down Expand Up @@ -202,6 +202,6 @@
"FoundMultipleFiles": "Found multiple files matching %s.",
"FailedToCreateFile": "Failed to create %s with error: %s.",
"FailedToFindFile": "Failed to find %s at %s.",
"DeprecatedTask": "The AppCenterDistribute@1 (App Center distribute) task has been deprecated since November 14, 2022 and will soon be retired. Use the AppCenterDistribute@3 task instead."
"DeprecatedTask": "The AppCenterDistribute@1 (App Center distribute) task has been deprecated since November 14, 2022 and will soon be retired. Use the AppCenterDistribute@3 task instead. Please visit https://aka.ms/azdo-deprecated-tasks to learn more about deprecated tasks."
}
}
2 changes: 1 addition & 1 deletion Tasks/AppCenterDistributeV1/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"version": {
"Major": 1,
"Minor": 235,
"Patch": 0
"Patch": 2
},
"minimumAgentVersion": "2.144.0",
"releaseNotes": "ms-resource:loc.releaseNotes",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@
"loc.messages.FoundMultipleFiles": "Found multiple files matching %s.",
"loc.messages.FailedToCreateFile": "Failed to create %s with error: %s.",
"loc.messages.FailedToFindFile": "Failed to find %s at %s.",
"loc.messages.DeprecatedTask": "The AppCenterDistribute@2 (App Center distribute) task has been deprecated since November 14, 2022 and will soon be retired. Use the AppCenterDistribute@3 task instead."
"loc.messages.DeprecatedTask": "The AppCenterDistribute@2 (App Center distribute) task has been deprecated since November 14, 2022 and will soon be retired. Use the AppCenterDistribute@3 task instead. Please visit https://aka.ms/azdo-deprecated-tasks to learn more about deprecated tasks."
}
4 changes: 2 additions & 2 deletions Tasks/AppCenterDistributeV2/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"version": {
"Major": 2,
"Minor": 235,
"Patch": 0
"Patch": 2
},
"minimumAgentVersion": "2.144.0",
"releaseNotes": "Added support for multiple destinations.",
Expand Down Expand Up @@ -204,6 +204,6 @@
"FoundMultipleFiles": "Found multiple files matching %s.",
"FailedToCreateFile": "Failed to create %s with error: %s.",
"FailedToFindFile": "Failed to find %s at %s.",
"DeprecatedTask": "The AppCenterDistribute@2 (App Center distribute) task has been deprecated since November 14, 2022 and will soon be retired. Use the AppCenterDistribute@3 task instead."
"DeprecatedTask": "The AppCenterDistribute@2 (App Center distribute) task has been deprecated since November 14, 2022 and will soon be retired. Use the AppCenterDistribute@3 task instead. Please visit https://aka.ms/azdo-deprecated-tasks to learn more about deprecated tasks."
}
}
2 changes: 1 addition & 1 deletion Tasks/AppCenterDistributeV2/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"version": {
"Major": 2,
"Minor": 235,
"Patch": 0
"Patch": 2
},
"minimumAgentVersion": "2.144.0",
"releaseNotes": "ms-resource:loc.releaseNotes",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"loc.helpMarkDown": "[Learn more about this task](https://aka.ms/armtaskreadme)",
"loc.description": "Deploy an Azure Resource Manager (ARM) template to all the deployment scopes",
"loc.instanceNameFormat": "ARM Template deployment: $(deploymentScope) scope",
"loc.releaseNotes": "- Added support for deployment at all the deployment scopes.\n- Removed all the VM related actions.",
"loc.releaseNotes": "- Added support for bicepparam.",
"loc.group.displayName.AzureDetails": "Azure Details",
"loc.group.displayName.Template": "Template",
"loc.group.displayName.Advanced": "Advanced",
Expand All @@ -27,7 +27,7 @@
"loc.input.label.csmFile": "Template",
"loc.input.help.csmFile": "Specify the path or a pattern pointing to the Azure Resource Manager template. For more information about the templates see https://aka.ms/azuretemplates. To get started immediately use template https://aka.ms/sampletemplate. 'Linked artifact' also has support for Bicep files when the Azure CLI version > 2.20.0",
"loc.input.label.csmParametersFile": "Template parameters",
"loc.input.help.csmParametersFile": "Specify the path or a pattern pointing for the parameters file for the Azure Resource Manager template. 'Linked artifact' also has support for Bicep files when the Azure CLI version > 2.20.0",
"loc.input.help.csmParametersFile": "Specify the path or a pattern pointing for the parameters file for the Azure Resource Manager template. 'Linked artifact' also has support for Bicep Param files when the Azure CLI version > 2.47.0",
"loc.input.label.overrideParameters": "Override template parameters",
"loc.input.help.overrideParameters": "To view the template parameters in a grid, click on “…” next to Override Parameters textbox. This feature requires that CORS rules are enabled at the source. If templates are in Azure storage blob, refer to [this](https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/Cross-Origin-Resource-Sharing--CORS--Support-for-the-Azure-Storage-Services?redirectedfrom=MSDN#understanding-cors-requests) to enable CORS. Or type the template parameters to override in the textbox. Example, <br>–storageName fabrikam –adminUsername $(vmusername) -adminPassword $(password) –azureKeyVaultName $(fabrikamFibre).<br>If the parameter value you're using has multiple words, enclose them in quotes, even if you're passing them using variables. For example, -name \"parameter value\" -name2 \"$(var)\"<br>To override object type parameters use stringified JSON objects. For example, -options [\"option1\"] -map {\"key1\": \"value1\" }. ",
"loc.input.label.deploymentMode": "Deployment mode",
Expand Down Expand Up @@ -99,5 +99,7 @@
"loc.messages.LoginFailed": "Azure login failed: %s",
"loc.messages.MSILoginFailed": "Azure login failed using Managed Service Identity: %s",
"loc.messages.AuthSchemeNotSupported": "Auth Scheme %s is not supported",
"loc.messages.ErrorInSettingUpSubscription": "Error in setting up subscription: %s"
"loc.messages.ErrorInSettingUpSubscription": "Error in setting up subscription: %s",
"loc.messages.BicepParamBuildFailed": "\"az bicep build-param\" failed. Error: %s",
"loc.messages.IncompatibleAzureCLIVersionBicepParam": "Azure CLI version should be >= 2.47.0 to use .bicepparam file"
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
param location string = 'eastasia'

var storageAccountName_var = 'deepak2121'
var storageAccountName = 'deepak2121'
var storageAccountType = 'Premium_LRS'

resource storageAccount 'Microsoft.Storage/storageAccounts@2021-01-01' = {
name: toLower(take(storageAccountName_var, 24))
name: toLower(take(storageAccountName, 24))
location: location
sku: {
name: storageAccountType
Expand All @@ -15,4 +15,4 @@ resource storageAccount 'Microsoft.Storage/storageAccounts@2021-01-01' = {
output storageAccount_Name string = storageAccount.name
output storageAccount_Location string = storageAccount.location
output storageAccount_SKUName string = storageAccount.sku.name
output storageAccount_Kind string = storageAccount.kind
output storageAccount_Kind string = storageAccount.kind
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
using 'CSMwithBicep.bicep'

param location = 'eastasia'
20 changes: 20 additions & 0 deletions Tasks/AzureResourceManagerTemplateDeploymentV3/Tests/L0.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,26 @@ describe('Azure Resource Manager Template Deployment', function () {
}
});

it('Successfully triggered createOrUpdate deployment using bicep file with bicepparam file', (done) => {
let tp = path.join(__dirname, 'createOrUpdate.js');
process.env["csmFile"] = "CSMwithBicep.bicep";
process.env["csmParametersFile"] = "CSMwithBicep.bicepparam";
process.env["deploymentOutputs"] = "someVar";
let tr = new ttm.MockTestRunner(tp);
tr.run();
try {
assert(tr.succeeded, "Should have succeeded");
assert(tr.stdout.indexOf("deployments.createOrUpdate is called") > 0, "deployments.createOrUpdate function should have been called from azure-sdk");
assert(tr.stdout.indexOf("##vso[task.setvariable variable=someVar;]") >= 0, "deploymentsOutput should have been updated");
done();
}
catch (error) {
console.log("STDERR", tr.stderr);
console.log("STDOUT", tr.stdout);
done(error);
}
});

// it('createOrUpdate deployment should fail when bicep file contains error', (done) => {
// let tp = path.join(__dirname, 'createOrUpdate.js');
// process.env["csmFile"] = "CSMwithBicepWithError.bicep";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,14 @@ process.env["ENDPOINT_AUTH_PARAMETER_AzureRM_AUTHENTICATIONTYPE"] = "key";

var CSMJson = path.join(__dirname, "CSM.json");
var CSMBicep = path.join(__dirname, "CSMwithBicep.bicep");
var CSMBicepParam = path.join(__dirname, "CSMwithBicep.bicepparam");
var CSMBicepWithWarning = path.join(__dirname, "CSMwithBicepWithWarning.bicep");
var CSMBicepWithError = path.join(__dirname, "CSMwithBicepWithError.bicep");
var CSMwithComments = path.join(__dirname, "CSMwithComments.json");
var defaults = path.join(__dirname, "defaults.json");
var faultyCSM = path.join(__dirname, "faultyCSM.json");
var bicepbuildCmd = `az bicep build --file ${path.join(__dirname, "CSMwithBicep.bicep")}`;
var bicepparambuildCmd = `az bicep build-params --file ${path.join(__dirname, "CSMwithBicep.bicepparam")} --outfile ${path.join(__dirname, "CSMwithBicep.parameters.json")}`;
var bicepbuildwithWarning = `az bicep build --file ${path.join(__dirname, "CSMwithBicepWithWarning.bicep")}`;
var azloginCommand = `az login --service-principal -u "id" --password="key" --tenant "tenant" --allow-no-subscriptions`;
var azaccountSet = `az account set --subscription "sId"`;
Expand All @@ -50,6 +52,7 @@ const successExec = {
"stdout": "Executed Successfully"
}
exec[bicepbuildCmd] = successExec;
exec[bicepparambuildCmd] = successExec;
exec[bicepbuildwithWarning] = successExec;
exec[azloginCommand] = successExec;
exec[azaccountSet] = successExec;
Expand All @@ -66,6 +69,7 @@ let a: ma.TaskLibAnswers = <ma.TaskLibAnswers>{
"findMatch": {
"CSM.json": [CSMJson],
"CSMwithBicep.bicep": [CSMBicep],
"CSMwithBicep.bicepparam": [CSMBicepParam],
"CSMwithBicepWithWarning.bicep": [CSMBicepWithWarning],
"CSMwithBicepWithError.bicep": [CSMBicepWithError],
"CSMwithComments.json": [CSMwithComments],
Expand All @@ -85,10 +89,14 @@ tr.registerMock('azure-pipelines-tasks-azure-arm-rest/azure-arm-resource', requi

const fsClone = Object.assign({}, fs);
fsClone.readFileSync = function(fileName: string): Buffer {
if (fileName.indexOf("CSMwithBicep") >= 0) {
if (fileName.indexOf("CSMwithBicep.json") >= 0 || fileName.indexOf("CSMwithBicepWithWarning.json") >= 0) {
const filePath = fileName.replace('.json', '.bicep');
cpExec(`az bicep build --file ${filePath}`);
}
else if (fileName.indexOf("CSMwithBicep.parameters.json") >= 0) {
const filePath = fileName.replace('.parameters.json', '.bicepparam');
cpExec(`az bicep build-params --file ${filePath} --outfile ${fileName}`);
}
var buffer = fs.readFileSync(fileName);
return buffer;
}
Expand Down
55 changes: 44 additions & 11 deletions Tasks/AzureResourceManagerTemplateDeploymentV3/operations/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -427,23 +427,34 @@ class Utils {

private static async getFilePathForLinkedArtifact(filePath: string, taskParameters: armDeployTaskParameters.TaskParameters): Promise<string> {
var filePathExtension: string = filePath.split('.').pop();
if(filePathExtension === 'bicep'){
if(filePathExtension.startsWith('bicep')){
let azcliversion = await this.getAzureCliVersion()
if(parseFloat(azcliversion)){
if(this.isBicepAvailable(azcliversion)){
if(this.isBicepAvailable(azcliversion, filePathExtension)){
setAzureCloudBasedOnServiceEndpoint(taskParameters.connectedService);
await loginAzureRM(taskParameters.connectedService);
await this.execBicepBuild(filePath)
filePath = filePath.replace('.bicep', '.json')
this.cleanupFileList.push(filePath)
if(filePathExtension === 'bicep'){
filePath = filePath.replace('.bicep', '.json')
}
else{
filePath = filePath.replace('.bicepparam', '.parameters.json')
}
await this.logoutAzure();
}else{
throw new Error(tl.loc("IncompatibleAzureCLIVersion"));
//Maintain backwards compatibility for runs that are not using bicep param and do not require higher version
if(filePathExtension === 'bicep'){
throw new Error(tl.loc("IncompatibleAzureCLIVersion"));
}
else{
throw new Error(tl.loc("IncompatibleAzureCLIVersionBicepParam"));
}
}
}else{
throw new Error(tl.loc("AzureCLINotFound"));
}
}

return filePath
}

Expand All @@ -463,10 +474,28 @@ class Utils {
}

private static async execBicepBuild(filePath): Promise<void> {
const result: IExecSyncResult = tl.execSync("az", `bicep build --file ${filePath}`);
if(result && result.code !== 0){
throw new Error(tl.loc("BicepBuildFailed", result.stderr));
var filePathExtension: string = filePath.split('.').pop();
var finalPathExtension: string = ".json"

if(filePathExtension === 'bicep'){
const result: IExecSyncResult = tl.execSync("az", `bicep build --file ${filePath}`);
if(result && result.code !== 0){
throw new Error(tl.loc("BicepBuildFailed", result.stderr));
}
}
else{
var fileName: string = filePath.split(path.sep).pop().split('.')[0];
var fileDir: string = filePath.replace(path.sep + fileName +'.bicepparam', '')
finalPathExtension = ".parameters.json"

//Using --outfile to avoid overwriting primary bicep file in the case bicep and param file have the the same file name.
const result: IExecSyncResult = tl.execSync("az", `bicep build-params --file ${filePath} --outfile ${path.join(fileDir, fileName + finalPathExtension)}`);
if(result && result.code !== 0){
throw new Error(tl.loc("BicepParamBuildFailed", result.stderr));
}
}

this.cleanupFileList.push(filePath.replace('.' + filePathExtension, finalPathExtension))
}

private static async logoutAzure() {
Expand All @@ -476,11 +505,15 @@ class Utils {
}
}

private static isBicepAvailable(azcliversion): Boolean{
private static isBicepAvailable(azcliversion,extension): Boolean{
let majorVersion = azcliversion.split('.')[0]
let minorVersion = azcliversion.split('.')[1]
// Support Bicep was introduced in az-cli 2.20.0
if((majorVersion == 2 && minorVersion >= 20) || majorVersion > 2){
// Support for Bicep format was introduced in az-cli 2.20.0
if(((majorVersion == 2 && minorVersion >= 20) && extension === 'bicep') || majorVersion > 2){
return true
}
// Support for Bicep Param format was introduced in az-cli 2.47.0
else if(((majorVersion == 2 && minorVersion >= 47) && extension === 'bicepparam') || majorVersion > 2){
return true
}
return false
Expand Down
8 changes: 5 additions & 3 deletions Tasks/AzureResourceManagerTemplateDeploymentV3/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
"helpUrl": "https://docs.microsoft.com/azure/devops/pipelines/tasks/deploy/azure-resource-group-deployment",
"helpMarkDown": "[Learn more about this task](https://aka.ms/armtaskreadme)",
"category": "Deploy",
"releaseNotes": "- Added support for deployment at all the deployment scopes.\n- Removed all the VM related actions.",
"releaseNotes": "- Added support for bicepparam.",
"visibility": [
"Build",
"Release"
],
"author": "Microsoft Corporation",
"version": {
"Major": 3,
"Minor": 231,
"Minor": 235,
"Patch": 0
},
"demands": [],
Expand Down Expand Up @@ -331,6 +331,8 @@
"LoginFailed": "Azure login failed: %s",
"MSILoginFailed": "Azure login failed using Managed Service Identity: %s",
"AuthSchemeNotSupported": "Auth Scheme %s is not supported",
"ErrorInSettingUpSubscription": "Error in setting up subscription: %s"
"ErrorInSettingUpSubscription": "Error in setting up subscription: %s",
"BicepParamBuildFailed": "\"az bicep build-param\" failed. Error: %s",
"IncompatibleAzureCLIVersionBicepParam": "Azure CLI version should be >= 2.47.0 to use .bicepparam file"
}
}
6 changes: 4 additions & 2 deletions Tasks/AzureResourceManagerTemplateDeploymentV3/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"author": "Microsoft Corporation",
"version": {
"Major": 3,
"Minor": 231,
"Minor": 235,
"Patch": 0
},
"demands": [],
Expand Down Expand Up @@ -331,6 +331,8 @@
"LoginFailed": "ms-resource:loc.messages.LoginFailed",
"MSILoginFailed": "ms-resource:loc.messages.MSILoginFailed",
"AuthSchemeNotSupported": "ms-resource:loc.messages.AuthSchemeNotSupported",
"ErrorInSettingUpSubscription": "ms-resource:loc.messages.ErrorInSettingUpSubscription"
"ErrorInSettingUpSubscription": "ms-resource:loc.messages.ErrorInSettingUpSubscription",
"BicepParamBuildFailed": "ms-resource:loc.messages.BicepParamBuildFailed",
"IncompatibleAzureCLIVersionBicepParam": "ms-resource:loc.messages.IncompatibleAzureCLIVersionBicepParam"
}
}
2 changes: 1 addition & 1 deletion Tasks/ChefKnifeV1/ChefKnife.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ try
}
if ($featureFlags.failDeprecatedBuildTask)
{
throw "The ChefKnife@1 (Run scripts with Knife commands on your Chef workstation) task has been deprecated since March 5, 2018 and will soon be retired. To continue to use Chef Knife, use the Knife client directly from a bash/pwsh/script task. See https://docs.chef.io/workstation/knife_client/."
throw "The ChefKnife@1 (Run scripts with Knife commands on your Chef workstation) task has been deprecated since March 5, 2018 and will soon be retired. To continue to use Chef Knife, use the Knife client directly from a bash/pwsh/script task. See https://docs.chef.io/workstation/knife_client/. Please visit https://aka.ms/azdo-deprecated-tasks to learn more about deprecated tasks."
}
}
finally
Expand Down
2 changes: 1 addition & 1 deletion Tasks/ChefKnifeV1/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"version": {
"Major": 1,
"Minor": 235,
"Patch": 0
"Patch": 1
},
"deprecated": true,
"removalDate": "2024-01-31",
Expand Down
2 changes: 1 addition & 1 deletion Tasks/ChefKnifeV1/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"version": {
"Major": 1,
"Minor": 235,
"Patch": 0
"Patch": 1
},
"deprecated": true,
"removalDate": "2024-01-31",
Expand Down
2 changes: 1 addition & 1 deletion Tasks/ChefV1/Chef.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ try
}
if ($featureFlags.failDeprecatedBuildTask)
{
throw "The Chef@1 (Deploy to Chef environments by editing environment attributes) task has been deprecated since March 5, 2018 and will soon be retired. To continue to use Chef, use the Chef CLI directly from a bash/pwsh/script task. See https://github.com/chef/chef-cli."
throw "The Chef@1 (Deploy to Chef environments by editing environment attributes) task has been deprecated since March 5, 2018 and will soon be retired. To continue to use Chef, use the Chef CLI directly from a bash/pwsh/script task. See https://github.com/chef/chef-cli. Please visit https://aka.ms/azdo-deprecated-tasks to learn more about deprecated tasks."
}
}
finally
Expand Down
Loading

0 comments on commit d6fe135

Please sign in to comment.