class AzureNetworkConnector implements NetworkConnector {

    @Override
    public CreatedCloudNetwork createNetworkWithSubnets(NetworkCreationRequest networkRequest) {
        AzureClient azureClient = azureClientService.getClient(networkRequest.getCloudCredential());
        String region = networkRequest.getRegion().value();
        List<SubnetRequest> subnetRequests = azureSubnetRequestProvider.provide(
                region,
                Lists.newArrayList(networkRequest.getPublicSubnets()),
                Lists.newArrayList(networkRequest.getPrivateSubnets()),
                networkRequest.isPrivateSubnetEnabled());

        Deployment templateDeployment;
        ResourceGroup resourceGroup;
        try {
            resourceGroup = getOrCreateResourceGroup(azureClient, networkRequest);
            String template = azureNetworkTemplateBuilder.build(networkRequest, subnetRequests, resourceGroup.name());
            String parametersMapAsString = new Json(Map.of()).getValue();
            templateDeployment = azureClient.createTemplateDeployment(resourceGroup.name(), networkRequest.getStackName(), template, parametersMapAsString);
        } catch (CloudException e) {
            LOGGER.info("Provisioning error, cloud exception happened: ", e);
            if (e.body() != null && e.body().details() != null) {
                String details = e.body().details().stream().map(CloudError::message).collect(Collectors.joining(", "));
                throw new CloudConnectorException(String.format("Network provisioning failed, status code %s, error message: %s, details: %s",
                        e.body().code(), e.body().message(), details));
            } else {
                throw new CloudConnectorException(String.format("Network provisioning failed: '%s', please go to Azure Portal for detailed message", e));
            }
        } catch (Exception e) {
            LOGGER.warn("Provisioning error:", e);
            throw new CloudConnectorException(String.format("Error in provisioning network %s: %s", networkRequest.getStackName(), e.getMessage()));
        }
        Map<String, Map> outputMap = (HashMap) templateDeployment.outputs();
        String networkName = cropId((String) outputMap.get(NETWORK_ID_KEY).get("value"));
        Set<CreatedSubnet> subnets = createSubnets(
                subnetRequests,
                outputMap,
                region);
        return new CreatedCloudNetwork(networkRequest.getStackName(), networkName, subnets,
                createProperties(resourceGroup.name(), networkRequest.getStackName()));
    }

}