Skip to content

Commit

Permalink
handle upgrade to new web.config. Removed dependent nuget with webjob…
Browse files Browse the repository at this point in the history
… files.
  • Loading branch information
sjkp committed Mar 24, 2016
1 parent 21d4575 commit 1666760
Show file tree
Hide file tree
Showing 13 changed files with 42 additions and 48 deletions.
3 changes: 0 additions & 3 deletions LetsEncrypt-SiteExtension.sln
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tools", "Tools", "{ED36B174-3C73-447F-A76F-5E8D23B8ADB3}"
ProjectSection(SolutionItems) = preProject
build.cmd = build.cmd
build.job.cmd = build.job.cmd
LetsEncrypt.nuspec = LetsEncrypt.nuspec
letsencrypt.siteextension.job.nuspec = letsencrypt.siteextension.job.nuspec
letsencrypt.siteextension.job64.nuspec = letsencrypt.siteextension.job64.nuspec
LetsEncrypt64.nuspec = LetsEncrypt64.nuspec
EndProjectSection
EndProject
Expand Down
8 changes: 5 additions & 3 deletions LetsEncrypt-SiteExtension/LetsEncrypt.SiteExtension.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,11 @@
<Content Include="applicationHost.xdt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="install.cmd" />
<Content Include="install64.cmd" />
<None Include="Scripts\jquery-1.10.2.intellisense.js" />
<Content Include="Scripts\jquery-1.10.2.js" />
<Content Include="Scripts\jquery-1.10.2.min.js" />
<Content Include="Scripts\modernizr-2.6.2.js" />
<Content Include="uninstall.cmd" />
<Content Include="Web.config" />
</ItemGroup>
<ItemGroup>
Expand Down Expand Up @@ -224,7 +223,7 @@
<Content Include="Views\Home\Install.cshtml" />
<Content Include="Views\Home\AddHostname.cshtml" />
<Content Include="Views\Home\CreateServicePrincipal.cshtml" />
<Content Include="uninstall.cmd" />
<Content Include="install.cmd" />
<None Include="Web.Debug.config">
<DependentUpon>Web.config</DependentUpon>
</None>
Expand Down Expand Up @@ -276,6 +275,9 @@
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup>
<RunPostBuildEvent>Always</RunPostBuildEvent>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\LetsEncrypt.SiteExtension.Core\LetsEncrypt.SiteExtension.Core.csproj">
<Project>{284f0226-f481-4c10-a408-4146fdbb71cc}</Project>
Expand Down
2 changes: 1 addition & 1 deletion LetsEncrypt-SiteExtension/Views/Shared/_Layout.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li><a href="/azurejobs/#/jobs/continuous/letsencrypt.siteextension.job">Web Jobs</a></li>
<li><a href="/azurejobs/#/jobs">Web Jobs</a></li>
</ul>
</div>
</div>
Expand Down
13 changes: 1 addition & 12 deletions LetsEncrypt-SiteExtension/install.cmd
Original file line number Diff line number Diff line change
@@ -1,15 +1,4 @@
cd /D %TEMP%
IF EXIST letsencrypt.siteextension.job (
rd /S /q letsencrypt.siteextension.job
)
mkdir letsencrypt.siteextension.job
cd letsencrypt.siteextension.job
nuget install letsencrypt.siteextension.job -Pre

SET JOB_FOLDER="%WEBROOT_PATH%\App_Data\jobs\continuous\letsencrypt.siteextension.job"
IF EXIST %JOB_FOLDER% (
rd /S /q %JOB_FOLDER%
)
mkdir %JOB_FOLDER%
cd letsencrypt.siteextension.job*
xcopy content %JOB_FOLDER% /E /C
)
15 changes: 0 additions & 15 deletions LetsEncrypt-SiteExtension/install64.cmd

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
<Content Include="Templates\azuredeploy.site.json" />
<Content Include="Templates\azuredeploy.json" />
<Content Include="Templates\azuredeploy.parameters.json" />
<None Include="Templates\azuredeploy.parameters.local.json" />
<None Include="Templates\azuredeploy.serviceplan.json" />
</ItemGroup>
<Target Name="GetReferenceAssemblyPaths" />
Expand Down
12 changes: 6 additions & 6 deletions LetsEncrypt.SiteExtension.Core/CertificateManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ public class CertificateManager
</system.webServer>
</configuration>";
private static WebSiteManagementClient webSiteClient;
private static WebSiteManagementClient serverFarmClient;

public void SetupHostnameAndCertificate()
{
Expand Down Expand Up @@ -243,8 +242,7 @@ public static string RequestAndInstallInternal(Target target)
Trace.TraceError(e.ToString());
}
throw;
}
return null;
}
}

public static string GetCertificate(Target binding)
Expand Down Expand Up @@ -460,6 +458,7 @@ public static string Auto(Target binding)
public static void Install(Target target, string pfxFilename, X509Certificate2 certificate)
{
Console.WriteLine(String.Format("Installing certificate {0} on azure", pfxFilename));
Trace.TraceInformation(String.Format("Installing certificate {0} on azure", pfxFilename));
var bytes = File.ReadAllBytes(pfxFilename);
var pfx = Convert.ToBase64String(bytes);

Expand Down Expand Up @@ -505,8 +504,9 @@ public static AuthorizationState Authorize(Target target)
Directory.CreateDirectory(directory);
}
var webConfigPath = Path.Combine(directory, "web.config");
if (!File.Exists(webConfigPath))
if (!File.Exists(webConfigPath) || File.ReadAllText(webConfigPath) != webConfig)
{
Trace.TraceInformation($"Writing web.config to {webConfigPath}");
File.WriteAllText(webConfigPath, webConfig);
}

Expand Down Expand Up @@ -567,8 +567,8 @@ public static AuthorizationState Authorize(Target target)
while (authzState.Status == "pending" && retry < 6)
{
retry++;
Console.WriteLine(" Refreshing authorization attempt" + retry);
Trace.TraceInformation("Refreshing authorization attempt" + retry);
Console.WriteLine(" Refreshing authorization attempt " + retry);
Trace.TraceInformation("Refreshing authorization attempt " + retry);
Thread.Sleep(4000); // this has to be here to give ACME server a chance to think
var newAuthzState = client.RefreshIdentifierAuthorization(authzState);
if (newAuthzState.Status != "pending")
Expand Down
8 changes: 6 additions & 2 deletions LetsEncrypt.SiteExtension.Core/WebAppEnviromentVariables.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ public class WebAppEnviromentVariables
{
private Guid subscriptionId;
private string resourceGroupName;
private string webSpace;

public WebAppEnviromentVariables()
{
Expand All @@ -21,6 +20,11 @@ public WebAppEnviromentVariables()
private void ParserWebSiteOwner()
{
var websiteowner = ConfigurationManager.AppSettings["WEBSITE_OWNER_NAME"];
if (string.IsNullOrEmpty(websiteowner))
{
Trace.TraceInformation("App Setting WEBSITE_OWNER_NAME is null or empty");
return;
}
try {

//format: 688bf064-900b-4e8f-9598-2d9be0718133+Tiimo.Web.Dev1-WestEuropewebspace
Expand All @@ -30,7 +34,7 @@ private void ParserWebSiteOwner()
resourceGroupName = string.Join("-", arr.Take(arr.Length - 1));
} catch(Exception ex)
{
Trace.TraceWarning(string.Format("unable to parse WEBSITE_OWNER_NAME '{0}'", websiteowner));
Trace.TraceError(string.Format("unable to parse WEBSITE_OWNER_NAME '{0}' exception '{1}'", websiteowner, ex.ToString()));
}
}

Expand Down
2 changes: 1 addition & 1 deletion LetsEncrypt.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<metadata>
<id>letsencrypt</id>
<title>Azure Let's Encrypt (x86)</title>
<version>0.4.11</version>
<version>0.4.15</version>
<authors>SJKP</authors>
<licenseUrl>http://opensource.org/licenses/Apache-2.0</licenseUrl>
<projectUrl>https://github.com/sjkp/letsencrypt-siteextension</projectUrl>
Expand Down
2 changes: 1 addition & 1 deletion LetsEncrypt64.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<metadata>
<id>letsencrypt64</id>
<title>Azure Let's Encrypt (x64)</title>
<version>0.4.11</version>
<version>0.4.15</version>
<authors>SJKP</authors>
<licenseUrl>http://opensource.org/licenses/Apache-2.0</licenseUrl>
<projectUrl>https://github.com/sjkp/letsencrypt-siteextension</projectUrl>
Expand Down
4 changes: 4 additions & 0 deletions artifacts64/install.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
SET JOB_FOLDER="%WEBROOT_PATH%\App_Data\jobs\continuous\letsencrypt.siteextension.job"
IF EXIST %JOB_FOLDER% (
rd /S /q %JOB_FOLDER%
)
4 changes: 4 additions & 0 deletions artifacts64/uninstall.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
SET JOB_FOLDER="%WEBROOT_PATH%\App_Data\jobs\continuous\letsencrypt.siteextension.job"
IF EXIST %JOB_FOLDER% (
rd /S /q %JOB_FOLDER%
)
16 changes: 12 additions & 4 deletions build.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,23 @@ nuget restore
md artifacts\bin
"C:\Program Files (x86)\MSBuild\14.0\bin\MSBuild.exe" LetsEncrypt-SiteExtension\LetsEncrypt.SiteExtension.csproj /t:pipelinePreDeployCopyAllFilesToOneFolder /p:Platform=x86 /p:_PackageTempDir="..\artifacts";AutoParameterizationWebConfigConnectionStrings=false;Configuration=Release;SolutionDir="."
"C:\Program Files (x86)\MSBuild\14.0\bin\MSBuild.exe" LetsEncrypt.SiteExtension.Core\LetsEncrypt.SiteExtension.Core.csproj /p:Platform=x86;Configuration=Release;SolutionDir="."
"C:\Program Files (x86)\MSBuild\14.0\bin\MSBuild.exe" LetsEncrypt.SiteExtension.WebJob\LetsEncrypt.SiteExtension.WebJob.csproj /p:Platform=x86;Configuration=Release;SolutionDir="."
xcopy LetsEncrypt.SiteExtension.Core\bin\x86\Release\*.* artifacts\bin /sy

md artifacts\app_data\jobs\continuous\letsencrypt.siteextension.job
xcopy LetsEncrypt.SiteExtension.Core\bin\x64\Release\*.* artifacts\app_data\jobs\continuous\letsencrypt.siteextension.job /sy
xcopy LetsEncrypt.SiteExtension.WebJob\bin\x64\Release\*.* artifacts\app_data\jobs\continuous\letsencrypt.siteextension.job /sy

nuget pack letsencrypt.nuspec

md artifacts64\bin
"C:\Program Files (x86)\MSBuild\14.0\bin\MSBuild.exe" LetsEncrypt-SiteExtension\LetsEncrypt.SiteExtension.csproj /t:pipelinePreDeployCopyAllFilesToOneFolder /p:Platform=x64 /p:_PackageTempDir="..\artifacts64";AutoParameterizationWebConfigConnectionStrings=false;Configuration=Release;SolutionDir="."
"C:\Program Files (x86)\MSBuild\14.0\bin\MSBuild.exe" LetsEncrypt.SiteExtension.Core\LetsEncrypt.SiteExtension.Core.csproj /p:Platform=x64;Configuration=Release;SolutionDir="."
"C:\Program Files (x86)\MSBuild\14.0\bin\MSBuild.exe" LetsEncrypt.SiteExtension.WebJob\LetsEncrypt.SiteExtension.WebJob.csproj /p:Platform=x64;Configuration=Release;SolutionDir="."
xcopy LetsEncrypt.SiteExtension.Core\bin\x64\Release\*.* artifacts64\bin /sy
cd artifacts
del install.cmd
ren install64.cmd install.cmd
cd..

md artifacts64\app_data\jobs\continuous\letsencrypt.siteextension.job
xcopy LetsEncrypt.SiteExtension.Core\bin\x64\Release\*.* artifacts64\app_data\jobs\continuous\letsencrypt.siteextension.job /sy
xcopy LetsEncrypt.SiteExtension.WebJob\bin\x64\Release\*.* artifacts64\app_data\jobs\continuous\letsencrypt.siteextension.job /sy

nuget pack letsencrypt64.nuspec

0 comments on commit 1666760

Please sign in to comment.