Tenho tentado usar a API REST do armazenamento de Blobs do Azure há alguns dias.
Posso me conectar ao recurso, listar contêineres e também gerar tokens SAS para qualquer contêiner sem problemas.
No entanto, agora estou tendo problemas ao tentar listar os blobs dentro de um contêiner usando o token SAS que gerei para o contêiner.
Com meu token SAS gerado, tentei o seguinte comando curl (retirado de https://learn.microsoft.com/en-us/rest/api/storageservices/list-blobs?tabs=microsoft-entra-id )
curl -X GET "https://dat3473spa01cfeMtest.blob.core.windows.net/90480397-91234697-218-test-dir01?restype=container&comp=list&?sv=2019-02-02&sr=c&sig=QlSozpknsTcR4frUK08%2FrcGaUGY893GzFN1Lyhl74Ao%3D&se=2024-10-24T07%3A50%3A11Z&sp=racwdl"
Onde https://dat3473spa01cfeMtest.blob.core.windows.net
está o blobServiceUri, 90480397-91234697-218-test-dir01
é o nome do contêiner e ?sv=2019-02-02&sr=c&sig=QlSozpknsTcR4frUK08%2FrcGaUGY893GzFN1Lyhl74Ao%3D&se=2024-10-24T07%3A50%3A11Z&sp=racwdl
é o token SAS que gerei para o contêiner em uma etapa anterior.
Ao executar o comando curl, recebo a seguinte mensagem de erro:
<?xml version="1.0" encoding="utf-8"?>
<Error>
<Code>AuthenticationFailed</Code>
<Message>Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.
RequestId:d370a92d-301e-0082-34ee-25f845000000
Time:2024-10-24T08:30:24.7319888Z</Message>
<AuthenticationErrorDetail>Signature fields not well formed.</AuthenticationErrorDetail>
</Error>
Presumo que o problema esteja relacionado à maneira como estou especificando o token SAS no comando curl, mas pela documentação no site mencionado anteriormente ( https://learn.microsoft.com/en-us/rest/api/storageservices/list-blobs?tabs=microsoft-entra-id
) não consigo ver como especificar o token SAS corretamente, se é que esse é o problema com meu comando curl.
Também tentei os seguintes comandos:
curl -X GET "https://dat3473spa01cfeMtest.blob.core.windows.net/90480397-91234697-218-test-dir01?restype=container&comp=list" -H "x-ms-version: 2025-01-05" -H "x-ms-date: Thu, 24 oct. 2024 08:29:07 GMT" -H "Authorization: ?sv=2019-02-02&sr=c&sig=QlSozpknsTcR4frUK08%2FrcGaUGY893GzFN1Lyhl74Ao%3D&se=2024-10-24T07%3A50%3A11Z&sp=racwdl"
curl -X GET "https://dat3473spa01cfeMtest.blob.core.windows.net/90480397-91234697-218-test-dir01?restype=container&comp=list" -H "x-ms-version: 2025-01-05" -H "x-ms-date: Thu, 24 oct. 2024 08:29:07 GMT" -H "Authorization: credential=?sv=2019-02-02&sr=c&sig=QlSozpknsTcR4frUK08%2FrcGaUGY893GzFN1Lyhl74Ao%3D&se=2024-10-24T07%3A50%3A11Z&sp=racwdl"
curl -X GET "https://dat3473spa01cfeMtest.blob.core.windows.net/90480397-91234697-218-test-dir01?restype=container&comp=list" -H "x-ms-version: 2025-01-05" -H "x-ms-date: Thu, 24 oct. 2024 08:29:07 GMT" -H "Authorization: credentials=?sv=2019-02-02&sr=c&sig=QlSozpknsTcR4frUK08%2FrcGaUGY893GzFN1Lyhl74Ao%3D&se=2024-10-24T07%3A50%3A11Z&sp=racwdl"
curl -X GET "https://dat3473spa01cfeMtest.blob.core.windows.net/90480397-91234697-218-test-dir01?restype=container&comp=list" -H "x-ms-version: 2025-01-05" -H "x-ms-date: Thu, 24 oct. 2024 08:29:07 GMT" -H "Authorization: token ?sv=2019-02-02&sr=c&sig=QlSozpknsTcR4frUK08%2FrcGaUGY893GzFN1Lyhl74Ao%3D&se=2024-10-24T07%3A50%3A11Z&sp=racwdl"
Todos eles dão o erro:
<Error>
<Code>InvalidAuthenticationInfo</Code>
<Message>Authentication information is not given in the correct format. Check the value of Authorization header.
RequestId:79a74d3f-101e-0071-5bf0-255fd0000000
Time:2024-10-24T08:44:39.7753277Z</Message>
</Error>