1-702-818-1043
support@quotaguard.com
Login

A Sample Code for Routing through QuotaGuard from Azure

Approximate time to read: 1 min


A Sample Code for Routing through QuotaGuard from Azure

If you find yourself trying to route through QuotaGuard from the Azure function App, we wanted to post this sample code as a possible solution.

var binding = new BasicHttpBinding();

binding.Security.Mode = BasicHttpSecurityMode.Transport;
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Certificate;

//Wrap binding custombinding to route request through proxy with credential authentication
var customBinding = new CustomBinding(binding);
var httpElement = customBinding.Elements.Find<HttpTransportBindingElement>();
httpElement.ProxyAddress = new Uri(Environment.GetEnvironmentVariable(ProxyURL));
httpElement.ProxyAuthenticationScheme = AuthenticationSchemes.Basic;
httpElement.UseDefaultWebProxy = false;

using (var webClient = new TransparencyPlatformClient(customBinding, FinalEndpoint)
{
	webClient.ClientCredentials.ClientCertificate.Certificate = Certificate;
 
	webClient.ClientCredentials.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.PeerOrChainTrust;
	var xmlString = XmlString(xml);

	webClient.ClientCredentials.UserName.UserName = ProxyUserName;
	webClient.ClientCredentials.UserName.Password = ProxyPassword;

	webClient.sendMessage(YourMessage);;
 }

We hope this helps, as always, any questions, shoot us an email at Support.


Ready to Get Started?

Get in touch or create a free trial account