Azure / azure-cli

Azure Command-Line Interface
MIT License
3.97k stars 2.95k forks source link

Gzip output getting mangled when piping to azure upload blob command #24761

Open RicardsRikmanis opened 1 year ago

RicardsRikmanis commented 1 year ago

Related command az storage blob upload --data @-

Describe the bug Gzip output is getting mangled when piping to azure upload blob command. No such issue if I split the the command, save the gziped file locally and then upload the file without the pipe. I'm pretty sure it has something to do with encoding getting mangled.

To Reproduce

  1. Have any file, for example - test.sql
    SHOW VARIABLES;
  2. Run similar command to this:
    cat test.sql | gzip | az storage blob upload --data @- -n test.sql.gz --account-name "$ACCOUNT" --container-name "$CONTAINER" --sas-token "$SAS_TOKEN
  3. Afterwards download the uploaded file from Azure Storage, attempt to un-compress it
    zcat test.sql.gz 
    gzip: test.sql.gz: not in gzip format

Expected behavior Gzip output can be piped to azure upload blob command without corrupting data.

Environment summary OS - Debian 10 azure-cli - 2.42.0

yonzhan commented 1 year ago

@evelyn-ys for awareness