Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Helper Function to set settings - potential better way to extract keyvalue pair? #562

Closed
KristofKlein opened this issue Aug 6, 2024 · 2 comments
Labels

Comments

@KristofKlein
Copy link
Contributor

Hi,

I was playing around with docker compose to start Business Central container, and wanted to add the InstrumentationString.

This failed as the Instrumentation string itself consists out of several key/value pairs split by a '=' ... the function to set customSettings can not handle this.

so I was wondering if it would make sense to replace that logic with something like :

function Set-ConfigSetting { ...}
  foreach ($customSetting in $customSettingsArray) {
        # not so good:
        # $customSettingArray = $customSetting -split "="
        # $customSettingKey = $customSettingArray[0]
        # $customSettingValue = $customSettingArray[1]
        
        # maybe better ?!: mind the double assignment and the ,2
        $customSettingKey , $customSettingValue = $customSetting -split "=",2 

OutPut old code:

ApplicationInsightsConnectionString
InstrumentationKey (<- this is what it actually set on the ST Server)
GUUUUUIDDDD;IngestionEndpoint
https://SOME.applicationinsights.azure.com;LiveEndpoint
https://SOME.monitor.azure.com;ApplicationId
MOREGUUUID

Outpu new code:

ApplicationInsightsConnectionString
InstrumentationKey=GUUUUUUID;IngestionEndpoint=https://SOME.applicationinsights.azure.com;LiveEndpoint=https://SOME.monitor.azure.com;ApplicationId=MOREGUUID

Which looks more correct

@freddydk
Copy link
Contributor

freddydk commented Sep 6, 2024

You are right, that if the key or the value contains a = - then the logic doesn't work and since the key never contains a =, your suggestion should be fine.
Feel free to create a PR with this. I will deploy a preview version and it will be included in the next update (around mid september)

@KristofKlein
Copy link
Contributor Author

I really hope I did it right :D

freddydk added a commit that referenced this issue Oct 15, 2024
add support for values including a '=' like Instrumentation key #562

Co-authored-by: Freddy Kristiansen <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants