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.

Migration scripts not found when using Azure App Service

See original GitHub issue

Configuration: C# .Net 4.6.2 Azure SQL Server V12 Azure App Service

Migration Launcher:

try
{
	string connectionString = Settings.GetSettings().DatabaseConnectionString;
	SqlConnection cnx = new SqlConnection(connectionString);
	Evolve.Evolve evolve = new Evolve.Evolve(cnx, msg => Trace.TraceInformation(msg))
	{
		Driver = "SqlClient", //Connect to SQL Server
		Locations = new List<string> { "db/migrations" },
		IsEraseDisabled = true, //Do not allow Erasing of schema
		EnableClusterMode = true //Ensure that no other instances also attempt to migrate the database as the same time
	};

	evolve.Migrate();
}
catch (Exception ex)
{
	Trace.TraceError("Database migration failed.", ex);
	throw;
}
}

SQL files have been written and are uploaded to the web server:

image

During start the following logs are provided

Application: 2018-08-30T14:46:57  PID[5928] Information Executing Migrate...
Application: 2018-08-30T14:46:57  PID[5928] Information Evolve initialized.
Application: 2018-08-30T14:46:57  PID[5928] Information No metadata found.
Application: 2018-08-30T14:46:57  PID[5928] Information Database is up to date. No migration needed.

And a single blank changelog table has been created: image

As far as I can tell I’ve followed all the requirements for using Evolve but I’m unsure of how to troubleshoot this issue further, any assistance would be greatly appreciated.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
ld0614commented, Aug 30, 2018

Thanks for all your assistance, after a few experiments I discovered that the working directory on an Azure App Service is fixed to D:\Windows\System32. thus all uses of DirectoryInfo where branching off of there. using …/db/migrations" didn’t help either as this returned to the root of the D drive. To fix I added the following code:

string currentPath = System.Web.HttpContext.Current.Server.MapPath("~");
Locations = new List<string> { currentPath + "db\\migrations" },

This maps to the correct root folder which can then be changed to the correct relative folder.

To assist with future debugging may I suggest a branch from here: https://github.com/lecaillon/Evolve/blob/25dab78a7dd969ef4316063aa43b2fa1ed990329/src/Evolve/Migration/FileMigrationLoader.cs#L29 which would write a message if it was unable to locate the directory (ideally with the offending path)?

0reactions
lecailloncommented, Aug 30, 2018

Nice, i did not know. I will think about a way of logging locations that do not exist.

Can I change your title issue to something like: “Scripts not found in Azure App Service” ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshoot web apps migration issues - Azure
Error code Error message Trou... IISWebAppMigrationError Error occurred during app content copy operation. Chec... ResultFileContentJSONParseError Results in unexpected format. Cont...
Read more >
Applying migration script not working, no files to deploy
The pipeline is executed in the cloud, not running on my machine. I have tried setting the pipeline variable system.debug to true and...
Read more >
Laravel Deployment on App Service Linux -
This post provides information for creating, configuring, and deploying a Laravel application on App Service Linux.
Read more >
Migrating a Local Node Script to Azure Functions using VS ...
1. Install the Azure Functions Extension for VS Code · 2. Merge the Local Script Code into the Azure Function · 3. Create...
Read more >
Applying migration script not working, no files to deploy
Coding example for the question Applying migration script not working, no files ... How do I run a PowerShell script on an Azure...
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