question

Saurabh-4459 avatar image
0 Votes"
Saurabh-4459 asked Saurabh-4459 answered

Unable to set locale in my python code

The following code fails in my Python script:
locale.setlocale(locale.LC_NUMERIC, 'en_IN')

Locale -a command in powershell gives me the following:

C
C.UTF-8
en_US
en_US.utf8
POSIX

Requesting for help as I'm not sure how to add en_IN to the locale on my azure app and then use it in my Python code.
Thanks for your help.

azure-webapps
· 4
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@Saurabh-4459 Can you please confirm if you are using azure function or azure app service?

0 Votes 0 ·

Hi Mayank,
Thanks for your reply. We're using Azure app service.

I should have tagged it correctly.

Could you help with the solution?

Thanks,
Saurabh

0 Votes 0 ·

@Saurabh-4459 Thanks for the confirmation. The tags are updated now and I have updated azure-webapps team and someone from the team will assist you.
Appreciates your patience.

1 Vote 1 ·
Show more comments
PierreLucGiguere-5297 avatar image
1 Vote"
PierreLucGiguere-5297 answered Saurabh-4459 commented

Hi,

That changes things.

You have to customize the startup script and install locales and local-all following these steps: https://azureossd.github.io/2020/01/23/custom-startup-for-nodejs-python/

Source: https://github.com/MicrosoftDocs/azure-docs/issues/51974

· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi Pierre,

Thanks for the help. I used the startup script and it is working. I'm able to set the locale now.

Thanks for your help.

0 Votes 0 ·

Hi Pierre,
As I mentioned that I tried copying the startup.sh from /opt/startup/startup.sh to /home/startup.sh and then added the command to install locale. It works fine each time I need to restart the webapps.
However, each time I deploy a fresh copy - I have to repeat the process of copying the startup file, adding the install command for locale and then restarting the app.

This is because the folder /tmp/8d9475bdee165fb changes each time and the script fails when I re-deploy from my local git repository.

Any idea how I can do this without manually repeating the steps?
I tried adding the install command in a postdeployment script too. It gave me an error saying "no such file or directory, open '/appsvctmp/status.txt'

Thanks for your help.

0 Votes 0 ·
PierreLucGiguere-5297 avatar image
0 Votes"
PierreLucGiguere-5297 answered Saurabh-4459 edited

Hi,

en-IN seems to be the correct spelling.

Please refer to the following documentation:

https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-lcid/a9eac961-e77d-41a6-90a5-ce1a8b0cdb9c?redirectedfrom=MSDN

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi,

Thanks for your reply. Spelling isn't the issue as I've tried multiple variations (en_IN, en-IN, en_IN.utf8, en-IN.utf8, etc.) And several of these variations work on the development system.
additionally - en_GB, en-GB and variations fail too - on the azure cloud.

The issue seems to be with locale not being available on the azure system - as shown in the "locale -a" command. I'm trying to figure out how to make different locales available.

Thanks for your help.

0 Votes 0 ·
Saurabh-4459 avatar image
1 Vote"
Saurabh-4459 answered

Thanks for your support Pierre and Mayank.

Because of the change in the build process on Azure, the deployment no longer happens in a fixed folder.

I used the $APP_PATH variable in the startup script and it seems to be working now.

Thank you for your help.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.