Aztfexport automation in Azure DevOps
Hi All,
I'm trying to add aztfexport to the Azure DevOps pipeline. I have installed it on the Azure DevOps Agent, but when I try to export a resource, aztfexport prompts the following messages:
The output directory is not empty. Please choose one of actions below:
* Press "Y" to proceed that will likely pollute the existing files and cause errors
* Press "N" to append new files and add to the existing state instead
* Press other keys to quit
I tried some commands below, but I still can hit the same messages. I'm not sure how to disable the interactive mode for aztfexport.
aztfexport resource ${{ parameters.resource_id }} --non-interactive --continue --output-dir $(System.DefaultWorkingDirectory)/azure/deployment/${{ parameters.env }}/${{ parameters.project }}/test
aztfexport resource ${{ parameters.resource_id }} --non-interactive --force --output-dir $(System.DefaultWorkingDirectory)/azure/deployment/${{ parameters.env }}/${{ parameters.project }}/test
aztfexport resource ${{ parameters.resource_id }} --non-interactive --overwrite--output-dir $(System.DefaultWorkingDirectory)/azure/deployment/${{ parameters.env }}/${{ parameters.project }}/test
@chrischeung1126 Thank you for reaching out! Per the help message below:
$ aztfexport res -h
...
USAGE:
aztfexport resource [option] [<resourceId> | @<resourceIdFile>...]
...
The option comes before the arguments. Therefore, you shall do something like:
aztfexport resource --non-interactive --force --output-dir $(System.DefaultWorkingDirectory)/azure/deployment/${{ parameters.env }}/${{ parameters.project }}/test ${{ parameters.resource_id }}
Note that since the option --output-dir is not detected before in your case, you probably don't need the --force after you swap the order, if the output directory you've specified is guaranteed to exist and empty. Use --force with caution.
Hi Magdo,
I tried your pasted commands but still hit the same problem. There is no automation way for aztfexport?
Could you please share the exact command you've been running, and the corresponding error message?
Before running aztfexport command you need to disable telemetry using below command
aztfexport config set telemetry_enabled false
Also use -n option in aztfexport command to run it non-intractive.
choose windows agent in the Azure Devops pipeline along with above commands