question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[QUESTION]: Using appSettings.json with Azure Databricks job

See original GitHub issue

Hey, I am using an appSettings.json configuration file like this in my .NET Core project

var configuration = new ConfigurationBuilder()
                .SetBasePath(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location))
                .AddJsonFile("appSettings.json", false, true)
                .AddEnvironmentVariables()
                .Build();

And I have the following in my .csproj

<None Include="appSettings.json">
        <CopyToOutputDirectory>Always</CopyToOutputDirectory>
        <CopyToPublishDirectory>Always</CopyToPublishDirectory>
</None>

This works fine running locally through spark-submit

Now I have tried following the Databricks deployment tutorial and have used the Set Jar option when configuring a new job using the publish.zip generated from dotnet publish -c Release -f netcoreapp3.1 -r ubuntu.16.04-x64 which contains my appSettings.json file along with the .dll files etc.

When trying to run this in Databricks I am getting the following error:

Unhandled exception. System.IO.FileNotFoundException: The configuration file 'appSettings.json' was not found and is not optional. The physical path is '/databricks/driver/appSettings.json'.
   at Microsoft.Extensions.Configuration.FileConfigurationProvider.HandleException(ExceptionDispatchInfo info)
   at Microsoft.Extensions.Configuration.FileConfigurationProvider.Load(Boolean reload)
   at Microsoft.Extensions.Configuration.FileConfigurationProvider.Load()
   at Microsoft.Extensions.Configuration.ConfigurationRoot..ctor(IList`1 providers)
   at Microsoft.Extensions.Configuration.ConfigurationBuilder.Build()

How can I configure Databricks so that it finds the file? The guides mention to include dependencies inside db-init.sh but I am a bit unclear of how to do that, any help is much appreciated. Thank you!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
this-fifocommented, Nov 24, 2020

I guess I realize now uploading there would probably make it work with the Path function

My concern with using that location is that I don’t understand if that is permanent or what controls it, whereas using the root of publish.zip keeps things in my control and remove that step

Maybe that’s the solution for now?

I still would like to better understand how Databricks handle the executing assembly and why is it separate but I’m fine with the current workaround

Thank you for your help @elvaliuliuliu ! 🙇‍♂️

1reaction
elvaliuliuliucommented, Nov 24, 2020

@this-fifo Glad to hear you have a workaround for this issue. I am not so sure but from the error above, it shows the path is /databricks/driver/appSettings.json?

Read more comments on GitHub >

github_iconTop Results From Across the Web

App Settings in ASP.NET Core and Azure
NET Core app, I came across the question of how to override application settings after ... For now we will keep it simple...
Read more >
Read a configuration json file from Azure Blob Storage in ...
I am using Databricks and in the end I expect to read this json file(in fact is a dictionary) to have access to...
Read more >
Create and run Azure Databricks Jobs
This article details how to create and run Azure Databricks Jobs using the Jobs UI. To learn about configuration options for jobs and...
Read more >
Azure Batch Service - appsettings.json not found
I am executing the application using the following command line: /bin/sh -c $AZ_BATCH_APP_PACKAGE_app_jobs"/app.Jobs" -j "FeedUpdate" and it's ...
Read more >
Configure settings for Azure Databricks jobs
To change the configuration for a job: Click Jobs Icon Workflows in the sidebar. In the Name column, click the job name.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found