ohadschn / letsencrypt-webapp-renewer

[PLEASE USE FREE MS MANAGED CERTS INSTEAD] Simple WebJob-ready console application for renewing Azure Web App SSL certificates
https://www.ohadsoft.com/
Apache License 2.0
282 stars 51 forks source link

Shared configuration #79

Closed statler closed 5 years ago

statler commented 5 years ago

In the documentation, it suggests that a shared config may be used by omitting the site info

Shared configuration It is sometimes useful to share configuraiton settings beween web apps. For example, you might be using the same client credentials, the same subscription ID, or the same resource group for multiple web apps. In order to share a configuration setting between web apps, simply omit the webAppName- component of the configuration key. For example, in order to configure shared client credentials, set the letsencrypt:clientId app setting and letsencrypt:clientSecret connection string. These values will now be used by default for all configured web apps, unless explicitly overriden by setting the fully WebApp-qualified key name (by including the webAppName- component, e.g. letsencrypt:mySpecialSite-clientId). All settings except hostsmay be shared.

Is this the case? I get the following error, but I have definitely set letsencrypt:clientSecret, so my understanding is that I shouldn't have to set letsencrypt:cpDataCore-clientSecret. Is this right? config

[06/12/2019 06:45:14 > 7bd804: ERR ] [06/12/2019 06:45:14 > 7bd804: ERR ] Unhandled Exception: System.Configuration.ConfigurationErrorsException: Missing connection string 'letsencrypt:cpDataCore-clientSecret' [06/12/2019 06:45:14 > 7bd804: ERR ] at OhadSoft.AzureLetsEncrypt.Renewal.WebJob.AppSettings.AppSettingsReader.GetConnectionString(String key) in C:\projects\letsencrypt-webapp-renewer\OhadSoft.AzureLetsEncrypt.Renewal\OhadSoft.AzureLetsEncrypt.Renewal.WebJob\AppSettings\AppSettingsReader.cs:line 168 [06/12/2019 06:45:14 > 7bd804: ERR ] at OhadSoft.AzureLetsEncrypt.Renewal.WebJob.AppSettings.AppSettingsRenewalParamsReader.ResolveConnectionString(String key, String webApp, String commonConnectionString) in C:\projects\letsencrypt-webapp-renewer\OhadSoft.AzureLetsEncrypt.Renewal\OhadSoft.AzureLetsEncrypt.Renewal.WebJob\AppSettings\AppSettingsRenewalParamsReader.cs:line 259 [06/12/2019 06:45:14 > 7bd804: ERR ] at OhadSoft.AzureLetsEncrypt.Renewal.WebJob.AppSettings.AppSettingsRenewalParamsReader.GetWebAppRenewalInfo(String webApp, SharedRenewalParameters sharedRenewalParams) in C:\projects\letsencrypt-webapp-renewer\OhadSoft.AzureLetsEncrypt.Renewal\OhadSoft.AzureLetsEncrypt.Renewal.WebJob\AppSettings\AppSettingsRenewalParamsReader.cs:line 103 [06/12/2019 06:45:14 > 7bd804: ERR ] at OhadSoft.AzureLetsEncrypt.Renewal.WebJob.AppSettings.AppSettingsRenewalParamsReader.<>c__DisplayClass2_0.b0(String wa) in C:\projects\letsencrypt-webapp-renewer\OhadSoft.AzureLetsEncrypt.Renewal\OhadSoft.AzureLetsEncrypt.Renewal.WebJob\AppSettings\AppSettingsRenewalParamsReader.cs:line 35 [06/12/2019 06:45:14 > 7bd804: ERR ] at System.Linq.Enumerable.WhereSelectArrayIterator2.MoveNext() [06/12/2019 06:45:14 > 7bd804: ERR ] at System.Linq.Buffer1..ctor(IEnumerable1 source) [06/12/2019 06:45:14 > 7bd804: ERR ] at System.Linq.Enumerable.ToArray[TSource](IEnumerable1 source) [06/12/2019 06:45:14 > 7bd804: ERR ] at OhadSoft.AzureLetsEncrypt.Renewal.WebJob.AppSettings.AppSettingsRenewalParamsReader.Read() in C:\projects\letsencrypt-webapp-renewer\OhadSoft.AzureLetsEncrypt.Renewal\OhadSoft.AzureLetsEncrypt.Renewal.WebJob\AppSettings\AppSettingsRenewalParamsReader.cs:line 35 [06/12/2019 06:45:14 > 7bd804: ERR ] at OhadSoft.AzureLetsEncrypt.Renewal.WebJob.AppSettings.AppSettingsRenewer.d4.MoveNext() in C:\projects\letsencrypt-webapp-renewer\OhadSoft.AzureLetsEncrypt.Renewal\OhadSoft.AzureLetsEncrypt.Renewal.WebJob\AppSettings\AppSettingsRenewer.cs:line 29 [06/12/2019 06:45:15 > 7bd804: ERR ] --- End of stack trace from previous location where exception was thrown --- [06/12/2019 06:45:15 > 7bd804: ERR ] at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) [06/12/2019 06:45:15 > 7bd804: ERR ] at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) [06/12/2019 06:45:15 > 7bd804: ERR ] at OhadSoft.AzureLetsEncrypt.Renewal.WebJob.Program.WebJobMain(String webjobName) in C:\projects\letsencrypt-webapp-renewer\OhadSoft.AzureLetsEncrypt.Renewal\OhadSoft.AzureLetsEncrypt.Renewal.WebJob\Program.cs:line 60 [06/12/2019 06:45:15 > 7bd804: ERR ] at OhadSoft.AzureLetsEncrypt.Renewal.WebJob.Program.Main(String[] args) in C:\projects\letsencrypt-webapp-renewer\OhadSoft.AzureLetsEncrypt.Renewal\OhadSoft.AzureLetsEncrypt.Renewal.WebJob\Program.cs:line 35

statler commented 5 years ago

Actually, it seems like it has some different issue - if I set the property explicitly, I still get the following - seems no clientSecret recognised. Same as if I delete the poperty entirely. I am pretty sure the value is right - I use letsencrypt:cpDataCore-clientSecret or letsencrypt:clientSecret - anything I should check?

[06/12/2019 07:32:26 > 7bd804: INFO] AzureLetsEncryptRenewer.exe Information: 0 : Parsed shared parameters: WebAppEnvironment: TenantId: dennisgascoignegmail.onmicrosoft.com, SubscriptionId: xxxxxxx-a1a0-4ba1-997e-8e2e7xxxxx, ResourceGroup: , ClientId: xxxxxxx-e5ea-46b5-a1cc-d40exxxxx, Email: xx@xxx.com, ServicePlanResourceGroup: , AzureDnsEnvironment: TenantId: , SubscriptionId: , ResourceGroup: , ClientId: , AzureDnsZoneName: , AzureDnsRelativeRecordSetName: , UseIpBasedSsl: , RsaKeyLength: , AcmeBaseUri: , WebRootPath: , RenewXNumberOfDaysBeforeExpiration: , AuthenticationUri: , AzureTokenAudience: , AzureManagementEndpoint: , AzureDefaultWebsiteDomainName: [06/12/2019 07:32:26 > 7bd804: INFO] AzureLetsEncryptRenewer.exe Information: 0 : Parsing SSL renewal parameters for web app 'cpDataCore'... [06/12/2019 07:32:26 > 7bd804: INFO] AzureLetsEncryptRenewer.exe Error: 0 : Unexpected exception: System.Configuration.ConfigurationErrorsException: Missing connection string 'letsencrypt:cpDataCore-clientSecret'

ohadschn commented 5 years ago

Per the docs, clientSecret should be a connection string, not regular config value.

statler commented 5 years ago

For anyone who is a bit special like me and didn't actually realise what this means, there are two sections in the configuration screen for the app. At the top is the normal settings (where I had everything configured) and down the bottom is another section called connection strings.

I just had to move the clientSecret from the top section down into the bottom section - not up the top.