Azure / azure-cli

Azure Command-Line Interface
MIT License
3.99k stars 2.97k forks source link

az rest does not support POSTing binary data #22810

Open bb-froggy opened 2 years ago

bb-froggy commented 2 years ago

Related command az rest

Is your feature request related to a problem? Please describe. I want to upload a logo for an application registration. MS Graph requires this to be uploaded binary, but az rest Base64-encodes it. I tried az rest --method put --headers ContentType=image/png --url https://graph.microsoft.com/v1.0/applications/0b1ec71d-0f88-a661-1ca7-104888888888/logo --body @image.png

Describe the solution you'd like az rest should support a parameter to read the body from a file binary, like --body-file. Alternatively, enforce uploading the data as-is via a parameter (would also fix this: )

Describe alternatives you've considered It is possible to upload a logo using other REST clients, like the .NET Graph Client.

az ad app update does not offer any parameter to upload a logo.

Additional context This addition would also solve this use case: https://stackoverflow.com/questions/63413704/azure-cli-rest-issue-with-encoding-german-umlauts

yonzhan commented 2 years ago

@jiasli for awareness

jiasli commented 2 years ago

Thanks for reporting this issue and I will take a look, but please be aware that using az rest to call MS Graph is not an officially warranted usage (https://github.com/Azure/azure-cli/issues/22580#issuecomment-1150686865).

jimdigriz commented 1 month ago

This also makes difficult amending page blobs in place as az storage blob ... does not allow the user to provide a value for range either.

Falling back to a ghetto az account get-access-token ... and curl...