use of com.azure.core.http.HttpPipeline 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.HttpPipeline in project ApplicationInsights-Java by microsoft.
the class ProfilerFrontendClientV2Test method uploadFinishedHitsCorrectUrl.
@Test
void uploadFinishedHitsCorrectUrl() throws IOException {
AtomicReference<HttpRequest> requestHolder = new AtomicReference<>();
HttpPipeline httpPipeline = new HttpPipelineBuilder().httpClient(request -> {
requestHolder.set(request);
return Mono.just(mockResponse(request, 201, "{\"acceptedTime\":\"a-time\",\"blobUri\":\"a-blob-uri\",\"correlationId\":\"a-correlation-id\",\"stampId\":\"a-stamp\"}"));
}).build();
ProfilerFrontendClientV2 profilerFrontendClientV2 = new ProfilerFrontendClientV2(new URL("http://a-host"), "a-instrumentation-key", httpPipeline);
UUID id = UUID.randomUUID();
ArtifactAcceptedResponse artifactAcceptedResponse = profilerFrontendClientV2.reportUploadFinish(id, "an-etag").block();
HttpRequest request = requestHolder.get();
String url = request.getUrl().toString();
assertThat(request.getHttpMethod()).isEqualTo(HttpMethod.POST);
assertThat(url.contains("/api/apps/a-instrumentation-key/artifactkinds/profile/artifacts/" + id)).isTrue();
assertThat(url.contains("action=commit")).isTrue();
assertThat(artifactAcceptedResponse.getAcceptedTime()).isEqualTo("a-time");
assertThat(artifactAcceptedResponse.getBlobUri()).isEqualTo("a-blob-uri");
assertThat(artifactAcceptedResponse.getCorrelationId()).isEqualTo("a-correlation-id");
assertThat(artifactAcceptedResponse.getStampId()).isEqualTo("a-stamp");
}
use of com.azure.core.http.HttpPipeline in project ApplicationInsights-Java by microsoft.
the class ProfilerServiceInitializer method initialize.
public static synchronized void initialize(Supplier<String> appIdSupplier, String processId, ServiceProfilerServiceConfig config, String machineName, String roleName, TelemetryClient telemetryClient, String userAgent, GcEventMonitor.GcEventMonitorConfiguration gcEventMonitorConfiguration) {
HttpPipeline httpPipeline = LazyHttpClient.newHttpPipeLine(telemetryClient.getAadAuthentication(), null);
initialize(appIdSupplier, processId, config, machineName, roleName, telemetryClient, userAgent, gcEventMonitorConfiguration, httpPipeline);
}
Aggregations