public async Task TestRequestAndInstallCertificate()
        {
            var config     = new AppSettingsAuthConfig();
            var client     = ArmHelper.GetWebSiteManagementClient(config);
            var kuduClient = KuduHelper.GetKuduClient(client, config);

            var body = new HttpKuduInstallModel()
            {
                AzureEnvironment = new AzureWebAppEnvironment(config.Tenant, config.SubscriptionId, config.ClientId, config.ClientSecret, config.ResourceGroupName, config.WebAppName),
                AcmeConfig       = new AcmeConfig()
                {
                    Host              = "letsencrypt.sjkp.dk",
                    PFXPassword       = "******",
                    RegistrationEmail = "*****@*****.**",
                    RSAKeyLength      = 2048
                },
                AuthorizationChallengeProviderConfig = new AuthorizationChallengeProviderConfig(),
                CertificateSettings = new CertificateServiceSettings()
            };

            var res = await kuduClient.HttpClient.PostAsync(
                "https://webappcfmv5fy7lcq7o.scm.azurewebsites.net/letsencrypt/api/certificates/challengeprovider/http/kudu/certificateinstall/azurewebapp?api-version=2017-09-01",
                new StringContent(JsonConvert.SerializeObject(body), Encoding.UTF8, "application/json"));

            await ValidateResponse(body.AcmeConfig, res);
        }
        public async Task <IHttpActionResult> GenerateAndInstall(HttpKuduInstallModel model, [FromUri(Name = "api-version")] string apiversion = null)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var mgr = CertificateManager.CreateKuduWebAppCertificateManager(model.AzureEnvironment, model.AcmeConfig, model.CertificateSettings, model.AuthorizationChallengeProviderConfig);

            return(Ok(await mgr.AddCertificate()));
        }