You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am facing this issue only in runtime in azure, in local it works fine for me. even after i hardcoded the connectionstring in the program.cs
Program.cs
varhost=newHostBuilder().ConfigureFunctionsWebApplication().ConfigureServices((context,services)=>{stringconnectionString="Server=";if(string.IsNullOrEmpty(connectionString)){// Log an error or throw an exception if the connection string is not availablethrownewInvalidOperationException("Connection string is not set. ConnectionString: "+connectionString);}services.AddDbContext<mydbContext>((options)=>{options.UseNpgsql(connectionString, builder =>{builder.EnableRetryOnFailure(3,TimeSpan.FromSeconds(10),null);});},ServiceLifetime.Scoped);AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior",true);services.AddApplicationInsightsTelemetryWorkerService();services.ConfigureFunctionsApplicationInsights();}
even the throw new invalid operation is not getting logged .
Function App:
publicclassProjectChangeListener{privatereadonlyILogger<ProjectChangeListener>_logger;privatereadonlyMyDBContext_context;privatereadonlyIProjectService_projectService;publicProjectChangeListener(ILogger<ProjectChangeListener>logger,MyDBContextcontext,IProjectServiceprojectService){_logger=logger;_context=context;this._projectService=projectService;}[Function("ProjectChangeListener")]publicasyncTaskRunProjectChangeListener([ServiceBusTrigger("lot","build",Connection="XXXXXX_SERVICEBUS_CONNECTION_STRING")]ServiceBusReceivedMessagemessage,ServiceBusMessageActionsmessageActions){_logger.LogInformation("ProjectChangeListener Triggered");try{_logger.LogInformation("ProjectChangeListener Triggered Try Block");_logger.LogInformation("Message ID: {id}",message.MessageId);varrecievedMessage=message.Body.ToString();varlotDTO=JsonConvert.DeserializeObject<LotDTO>(recievedMessage);vardbProject=await_context.Projects.FindAsync(lotDTO.LotNo);if(dbProject==null){_logger.LogInformation("ProjectId Not found to Sync between HB1 and BetterBuild: {id}",lotDTO.LotNo);return;}varresponse=await_projectService.UpdateProjectAsync(lotDTO);if(!response.IsSuccessStatusCode){varerror=response.Content.ReadAsStringAsync();_logger.LogError($"Update project failed for projectId {lotDTO.LotNo} - {error}");}}catch(Exceptionex){_logger.LogError("ProjectChangeListener Failed"+ex.Message+"Stack Trace"+ex.StackTrace);throwex;}}
above is the function app works locally , totally fine, but when deployed and when the topic is picked up it fails.
The text was updated successfully, but these errors were encountered:
@Akhil1501 whether you're running on Azure or locally shouldn't have any bearing on how Npgsql of EF behaves - there's likely some sort of difference in how you configure or run your application on Azure. Double-check your Azure configuration/deployment to make sure everything is correct; otherwise, I'm going to need some sort of minimal, runnable repro in order to help further.
@Akhil1501 whether you're running on Azure or locally shouldn't have any bearing on how Npgsql of EF behaves - there's likely some sort of difference in how you configure or run your application on Azure. Double-check your Azure configuration/deployment to make sure everything is correct; otherwise, I'm going to need some sort of minimal, runnable repro in order to help further.
But if it was an issue with configuration that shouldnt been a problem, when i deleted the connection string created by script and added it myself, still same issue, in the code above, i have hardcoded the connection string. that shouldnt have been a problem right, I even tried removing all database operations, still it fails with the same reason.
I am facing this issue only in runtime in azure, in local it works fine for me. even after i hardcoded the connectionstring in the program.cs
Program.cs
even the throw new invalid operation is not getting logged .
Function App:
above is the function app works locally , totally fine, but when deployed and when the topic is picked up it fails.
The text was updated successfully, but these errors were encountered: