0

I've made a web app in .NET 6.0 using WTelegramClient. It works fine locally but when I try to publish it to Azure App Service i obtain the following error: HTTP Error 500.30 - ASP.NET Core app failed to start

I tried to remove WTelegramClient initialization from app and it works fine on Azure too.

This is my Config function:

public static string Config(string what)
        {   
            switch (what)
            {
                case "api_id": return Instance.m_oTgConfig.api_id;
                case "api_hash": return Instance.m_oTgConfig.api_hash;
                case "phone_number": return Instance.m_oTgConfig.phone_number;
                case "verification_code": Console.Write("Code: "); return Console.ReadLine();
                case "first_name": return Instance.m_oTgConfig.first_name;    // if sign-up is required
                case "last_name": return Instance.m_oTgConfig.last_name;        // if sign-up is required
                case "password": return Instance.m_oTgConfig.password;     // if user has enabled 2FA
                case "session_pathname": return "/WTelegram.session";
                default: return null; // let WTelegramClient decide the default config
            }
        }

Am I doing somethin wrong with the .session file?

I think that the problem is that I must to insert verification_code (telegram OTP) by hand from the console. In local I do it from the console. How can I do the same thing in Azure? If I run MyApp.exe from Azure's console it do not ask anything.

grrfnc
  • 19
  • 8
  • In Azure, you need to enable logging in web.config file - through Kudu services - and investigate the stack trace in the log file produced after you try to publish the app. I don't think this question has enough details to give proper solution – Yehor Androsov Mar 16 '23 at 14:41
  • Most likely, your appsettings.json is missing some parameters because of the environment. You could try to start with publishing application in Development configuration to see if it works – Yehor Androsov Mar 16 '23 at 14:45
  • In azure app configuration check if the process is set to 64 bit . Try changing it, then restarting the app – thanzeel Mar 16 '23 at 14:50
  • If I run MyApp.exe from Azure console i obtain: Unhandled exception: System.ApplicationException: You must provide a config value for verification_code. How do I insert my verification code from console if it do not ask for it? – grrfnc Mar 16 '23 at 15:32

1 Answers1

0

See WTelegramClient ASP.NET example for how to login & prompt for the verification_code interactively via a web page.

Make also sure session_pathname points inside a directory where you have read/write access so the session file can get saved there.

And before further questions, please read the ReadMe file and the FAQ page as they both answer your issue

Wizou
  • 1,336
  • 13
  • 24