-
Notifications
You must be signed in to change notification settings - Fork 853
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document the endpoint URL requirement for the various client constructors #19274
Comments
Hi @cmackenzie1. Thank you for your feedback and we will look into it soon. Meanwhile, feel free to share your experience using the Azure SDK in this survey. |
You can use Would you mind telling us a bit more about your scenario? When we redisgned |
I am working on upgrading the SDK for the integration at Cloudflare to push customers logs to Azure Blob storage 1. Customers will go through the process to create a storage account and a containter then generate a SAS token for us to use on their behalf. During the SAS create token flow in the UI, the user is presented with a URL in what looks like the format ie,
The customer then submits the entire SAS URL when creating a "Logpush" job. Previously, before the v0.5.0 version we simply just used the URL as provided to create a blob container client and then called
Going back to this, my understanding is that both Footnotes |
Thanks for sharing the details. Your understanding is correct. In our example, the thinking is that the client and its operations are hierarchical. You'd create the client for the service URL and then manipulate containers/blobs within in. You do bring up a good point though that if you start with a container/blob URL it's not very intuitive. I will discuss this with the team to see how we want to proceed. In the meantime, you have a few options.
|
Thanks for the quick responses @jhendrixMSFT , very much appreciated. I am OK with going the route creating the client and getting the container name from the URL. It seems the most straight forward and inline with the other object storage clients we use like S3 and GCS. client, err := azblob.NewClientWithNoCredential(blobUrl, nil)
parts, err := azblob.ParseURL(blobUrl)
if err != nil {
return nil, fmt.Errorf("invalid url: %v", err)
}
containerName = parts.ContainerName |
Just make sure that when you call |
Thanks. While testing I ran into interesting behavior so let me know if I should create a new issue or not for it. When doing the following I end up with an unnamed object under the prefix of parts, err := azblob.ParseURL(blobUrl)
if err != nil {
panic(fmt.Errorf("invalid url: %v", err))
}
client, err := azblob.NewClientWithNoCredential(parts.String(), nil)
if err != nil {
panic(fmt.Errorf("unable to create azure blob client: %v", err))
}
_, err := c.client.UploadStream(ctx, containerName, key, body, &azblob.UploadStreamOptions{
BlockSize: 2 * 1024 * 1024, // 2 MB
HTTPHeaders: &blob.HTTPHeaders{
BlobContentEncoding: &contentEncoding,
BlobContentType: &contentType,
},
}) |
This is what I was alluding to earlier. When you call one of the Upload APIs, it concatenates the |
I tried with just I was following this example, |
Found the underlying issue. It only occurs when the URL contains any query parameters. A final In go 1.19 a new method for joining URL paths was added, https://pkg.go.dev/net/[email protected]#JoinPath |
#19245 is in progress to get this fixed. |
Ah thank you @jhendrixMSFT. I know you mentioned / alluded to it before but wasn't sure if this was that very same behavior. I'll keep an eye on #19245. I think it's safe to close this issue now. |
I will keep this open to track fixing the docs so it's clear that the constructors take only the service URL (the context here is very helpful). |
@cmackenzie1 can I ask where you got the SAS URL in your earlier comment? Looks like we also add a superfluous trailing |
Oh looks like the portal provides this. |
Yup, the SAS URL was generated in the Azure UI. |
Feature Request
Previously, before
v0.5.0
, one could callUploadStream
without specifying the container name, which is already present in the URL when instantiating the client usingazblob.NewClientWithNoCredential
.Now with
v0.5.0
, you must specify the container name in theclient.UploadStream
args.Is it possible to get a utility function to get the container name from the URL used when creating the client?
The text was updated successfully, but these errors were encountered: