I have an Azure function that fetches decimal values (from api) and deserializes them (they have "." as decimal separator). When the function is executed locally the decimals are converted correctly, when instead it is executed by azure the decimals are not converted correctly and I find huge numbers. What can this be due to? I thought it could be related to the setting of the decimal separator, or related to the current culture. I would need help solving this problem. Thanks
Asked
Active
Viewed 255 times
1
-
1I would also bet on culture issues, but hard to tell without any code. – Klaus Gütter Aug 26 '22 at 14:14
-
1Can you classify what you mean is huge? Do you mean the values have lots of digits in the decimal place or do you mean the decima points is in the wrong location. Decimal places can be different characters depending on culture (commas or periods). Rounding for decimal conversion is a different issue. The rounding may be due to project being Debug vs Release. I've seen issues where in debug mode the conversion was done in software and in release conversion was done inside the microprocessor. – jdweng Aug 26 '22 at 14:35
-
Try setting the current thread culture using this method: https://stackoverflow.com/a/7536117/396005 – Bron Davies Aug 26 '22 at 14:44
-
@BronDavies your solution worked. Can you please write it as answer so I can accept it and it can be useful to other users with the same problem? Thanks – Cristiano Schiaffella Aug 26 '22 at 15:25
1 Answers
1
Try setting the current thread culture using this method: stackoverflow.com/a/7536117/396005
culture = CultureInfo.CreateSpecificCulture("en-US");
Thread.CurrentThread.CurrentCulture = culture;
Thread.CurrentThread.CurrentUICulture = culture;

Bron Davies
- 5,930
- 3
- 30
- 41