use of com.azure.core.http.policy.HttpPipelinePolicy in project azure-maven-plugins by microsoft.
the class AzureFunctionsResourceManager method getClient.
public static AzureFunctionsResourceManager getClient(@Nonnull WebAppBase functionApp, @Nonnull IFunctionAppBase appService) {
// com/azure/resourcemanager/appservice/implementation/KuduClient.java
if (!(functionApp instanceof FunctionApp || functionApp instanceof FunctionDeploymentSlot)) {
throw new AzureToolkitRuntimeException("Functions resource manager only applies to Azure Functions");
}
final List<HttpPipelinePolicy> policies = Utils.getPolicyFromPipeline(functionApp.manager().httpPipeline(), policy -> !(policy instanceof AuthenticationPolicy || policy instanceof ProviderRegistrationPolicy || policy instanceof AuxiliaryAuthenticationPolicy));
policies.add(new AddHeadersPolicy(new HttpHeaders(Collections.singletonMap("x-functions-key", appService.getMasterKey()))));
final HttpPipeline httpPipeline = new HttpPipelineBuilder().policies(policies.toArray(new HttpPipelinePolicy[0])).httpClient(functionApp.manager().httpPipeline().getHttpClient()).build();
final FunctionsService functionsService = RestProxy.create(FunctionsService.class, httpPipeline, SerializerFactory.createDefaultManagementSerializerAdapter());
return new AzureFunctionsResourceManager(functionsService, appService);
}
use of com.azure.core.http.policy.HttpPipelinePolicy in project ApplicationInsights-Java by microsoft.
the class TelemetryChannelTest method getTelemetryChannel.
private TelemetryChannel getTelemetryChannel() throws MalformedURLException {
List<HttpPipelinePolicy> policies = new ArrayList<>();
policies.add(new RedirectPolicy(Cache.bounded(5)));
HttpPipelineBuilder pipelineBuilder = new HttpPipelineBuilder().policies(policies.toArray(new HttpPipelinePolicy[0])).httpClient(recordingHttpClient);
LocalFileCache localFileCache = new LocalFileCache(tempFolder);
StatsbeatModule mockedStatsModule = Mockito.mock(StatsbeatModule.class);
when(mockedStatsModule.getNetworkStatsbeat()).thenReturn(Mockito.mock(NetworkStatsbeat.class));
return new TelemetryChannel(pipelineBuilder.build(), new URL(END_POINT_URL), new LocalFileWriter(localFileCache, tempFolder, null), mockedStatsModule, false);
}
Aggregations