Use proxy with Google.Cloud.Storage.V1
See original GitHub issueHello team,
By design in our “on prem” datacenter we need to use a proxy to go though internet. We have been able to upload some file to our GCS without any proxy but we are stuck to upload a file when we need to use a proxy.
We use:
- .NET Core 2
- Windows Server 2016 to run our website
Where should we define the proxy in the API ? We didn’t find any way to do it ! Is it even possible ? We tried several ways but without success.
Code is very basic :
using (StreamReader r = new StreamReader("xxxx.json"))
{
string jsonFromStream = r.ReadToEnd();
json = JsonConvert.DeserializeObject(jsonFromStream);
}
var credential = GoogleCredential.FromJson(json.ToString());
var storageClient = StorageClient.Create(credential);
storageClient.UploadObject("lr-xxxx-yyyy", "blogexample/image.png", null, image);
Thanks, Alexandre
Issue Analytics
- State:
- Created 6 years ago
- Comments:24 (2 by maintainers)
Top Results From Across the Web
Use target proxies | Load Balancing
Target proxies terminate incoming connections from clients and create new connections from the load balancer to the backends. Target proxies are referenced ...
Read more >Cloud Storage authentication
For more information about accessing Cloud Storage through a proxy server, see the Troubleshooting topic. User account credentials. Use user account credentials ...
Read more >Proxying requests to google cloud storage using Hadoop GCS ...
gs.storage.root.url and then run the command below. This will enable all the storage requests to flow through the proxy but the auth requests ......
Read more >Re: [google-cloud-sdk] access my gcloud through proxy
I download google-cloud-sdk and setup to access my cloud storage through proxy. According to some experience from internet. it's work fine when I...
Read more >Reverse proxy Google Cloud storage to authenticate ...
My main concern with this approach is that those endpoints would have a lot of traffic and the API reverse proxy wouldn't be...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@liiri Google.Cloud.Logging.V2 works over gRPC not over HTTP so the way to set a proxy is different. There are two steps:
For the credential, you use code just like the one above, i.e. create the credential with the HttpClientFactory that has a proxy set.
Then, create the service client as follows (which will make all auth related requests go through the proxy):
For gRPC requests (i.e. the actual logging requests) to use a proxy, then, you need to look at what Grpc.Core requieres. And that is to set any of a number of environment variables as described on the first point in gRPC environment variables docs. Also you might want to take a look at issues like https://github.com/grpc/grpc/issues/13323 and https://github.com/grpc/grpc/issues/12815 which are related. If you cannot make this part work, It’s better if you ask directly on https://github.com/grpc/grpc as we just rely on gRPC’s implementation for proxy setting.
For posterity, we now have a better way to set a proxy for Google.Cloud.Storage.V1. If you are using Google.Cloud.Storage.V1 v3.5.0 (which is the latest at the moment of writing this) or an older version, you need to add an explicit dependency on Google.Api.Gax.Rest version 3.4.0.