0
votes

I have an Azure CLI task which references a PowerShell script (via build artifact) running az commands. Most of these commands work successfully, but when attempting to execute the following command:

az appconfig kv import --name $resourceName -s file --path appconfig.json --format json

I've noticed that the information was not present against the Azure resource and the log file has "File is not available".

I must be referencing the file incorrectly from the build artifact but if anyone could provide some clarity around this that would be great.

2
Do you add $(System.ArtifactsDirectory)/xxx to the path? System.ArtifactsDirectory: The directory to which artifacts are downloaded during deployment of a release. In addition , you can set system.debug=true to get more detailed log and share the error message here.Hugh Lin
Not get your latest information, is the workaround helpful for you? Or if you have any concern, feel free to share it here.Hugh Lin
apologies on the delayed response I had tried a few different values last one was System.DefaultWorkingDirectoryPuffTMD
@HughLin-MSFT how/where do you add "system.debug=true"confused-nerd

2 Answers

0
votes

I must be referencing the file incorrectly from the build artifact

You can try to add $(System.ArtifactsDirectory) to the json file path. For example: --path $(System.ArtifactsDirectory)/appconfig.json.

System.ArtifactsDirectory: The directory to which artifacts are downloaded during deployment of a release. Example: C:\agent\_work\r1\a

For details ,please refer to predefined variables .

0
votes

This can be a little tricky to figure out.

System.ArtifactsDirectory is the default variable that indicates the directory to which artifacts are downloaded during deployment of a release.

However, to use a default variable in your script, you must first replace the . in the default variable names with _. For example, to print the value of artifact variable System.ArtifactsDirectory in a PowerShell script, you would have to use $env:SYSTEM_ARTIFACTSDIRECTORY.

I have a similar setup and do it this way within my PowerShell script:

# Define the path to the file
$appSettingsFile="$env:SYSTEM_ARTIFACTSDIRECTORY\<rest_of_the_path>\appconfig.json"

# Pass it to the Azure CLI command
az appconfig kv import -n $appConfigName -s file --path $appSettingsFile --format json --separator . --yes

It is also helpful to view the current values of all variables to see what they contain before using them.

References: