New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error establishing a database connection #249

Closed
slimmingworlduk opened this Issue Oct 9, 2017 · 9 comments

Comments

Projects
None yet
3 participants
@slimmingworlduk

slimmingworlduk commented Oct 9, 2017

Deployments to Azure seem to be failing.
Web app displays : Error establishing a database connection
Seems as if the wordpress SQL users aren't being created on the deploy

Seems to be caused by the sql script to create the wordpress user cannot contain a hyphen.

eg bloguser is ok but blog-user will fail

{"code":"DeploymentFailed","message":"At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-debug for usage details.","details":[{"code":"Conflict","message":"{\r\n "status": "failed",\r\n "error": {\r\n "code": "ResourceDeploymentFailure",\r\n "message": "The resource operation completed with terminal provisioning state 'failed'.",\r\n "details": [\r\n {\r\n "code": "Failed",\r\n "message": "Package deployment failed\r\nAppGallery Deploy Failed: 'Microsoft.Web.Deployment.DeploymentDetailedClientServerException: An error occurred during execution of the database script. The error occurred between the following lines of the script: \"1\" and \"5\". The verbose log might have more information about the error. The command started with the following:\r\n\"-- Add here a test to be sure the login does not e\"\r\n Incorrect syntax near '-'. http://go.microsoft.com/fwlink/?LinkId=178587 Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_SQL_EXECUTION_FAILURE. ---> System.Data.SqlClient.SqlException: Incorrect syntax near '-'.\r\n at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction)\\r\\n at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction)\r\n at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)\r\n at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)\r\n at System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async, Int32 timeout, Boolean asyncWrite)\r\n at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean&amp; usedCache, Boolean asyncWrite, Boolean inRetry)\\r\\n at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()\\r\\n at Microsoft.Web.Deployment.DBStatementInfo.Execute(DbConnection connection, DbTransaction transaction, DeploymentBaseContext baseContext, Int32 timeout)\\r\\n --- End of inner exception stack trace ---\\r\\n at Microsoft.Web.Deployment.DBStatementInfo.Execute(DbConnection connection, DbTransaction transaction, DeploymentBaseContext baseContext, Int32 timeout)\\r\\n at Microsoft.Web.Deployment.DBConnectionWrapper.ExecuteSql(DBStatementInfo sqlStatement, DeploymentBaseContext baseContext, Int32 timeout)\\r\\n at Microsoft.Web.Deployment.SqlScriptToDBProvider.AddHelper(DeploymentObject source, Boolean whatIf)\\r\\n at Microsoft.Web.Deployment.SqlScriptToDBProvider.Add(DeploymentObject source, Boolean whatIf)\\r\\n at Microsoft.Web.Deployment.DeploymentObject.AddChild(DeploymentObject source, Int32 position, DeploymentSyncContext syncContext)\\r\\n at Microsoft.Web.Deployment.DeploymentSyncContext.HandleAddChild(DeploymentObject destParent, DeploymentObject sourceObject, Int32 position)\\r\\n at Microsoft.Web.Deployment.DeploymentSyncContext.SyncChildrenOrder(DeploymentObject dest, DeploymentObject source)\\r\\n at Microsoft.Web.Deployment.DeploymentSyncContext.SyncChildren(DeploymentObject dest, DeploymentObject source)\\r\\n at Microsoft.Web.Deployment.DeploymentSyncContext.SyncChildrenOrder(DeploymentObject dest, DeploymentObject source)\\r\\n at Microsoft.Web.Deployment.DeploymentSyncContext.SyncChildren(DeploymentObject dest, DeploymentObject source)\\r\\n at Microsoft.Web.Deployment.DeploymentSyncContext.ProcessSync(DeploymentObject destinationObject, DeploymentObject sourceObject)\\r\\n at Microsoft.Web.Deployment.DeploymentObject.SyncToInternal(DeploymentObject destObject, DeploymentSyncOptions syncOptions, PayloadTable payloadTable, ContentRootTable contentRootTable, Nullable1 syncPassId, String syncSessionId)\r\n at Microsoft.Web.Deployment.DeploymentObject.SyncTo(DeploymentProviderOptions providerOptions, DeploymentBaseOptions baseOptions, DeploymentSyncOptions syncOptions)\r\n at Microsoft.Web.Deployment.DeploymentObject.SyncTo(String provider, String path, DeploymentBaseOptions baseOptions, DeploymentSyncOptions syncOptions)\r\n at Microsoft.Web.Deployment.DeploymentObject.SyncTo(DeploymentWellKnownProvider provider, String path, DeploymentBaseOptions baseOptions, DeploymentSyncOptions syncOptions)\r\n at Microsoft.Web.Deployment.WebApi.AppGalleryPackage.Deploy(String deploymentSite, String siteSlotId, Boolean doNotDelete)\r\n at Microsoft.Web.Deployment.WebApi.DeploymentController.<DownloadAndDeployPackage>d__13.MoveNext()'"\r\n }\r\n ]\r\n }\r\n}"}]}

@patrickebates

This comment has been minimized.

Show comment
Hide comment
@patrickebates

patrickebates Oct 29, 2017

Member

Unfortunately these errors are usually on the Azure automation side and beyond our control. Best we can recommend is to wait and try again later.

Member

patrickebates commented Oct 29, 2017

Unfortunately these errors are usually on the Azure automation side and beyond our control. Best we can recommend is to wait and try again later.

@slimmingworlduk

This comment has been minimized.

Show comment
Hide comment
@slimmingworlduk

slimmingworlduk Oct 30, 2017

We found the issue was with the script creating the SQL logins. We chose a hyphenated username eg, 'my-user'. The current script will crash in this case as the [] are missing from the create statement. Updating to use 'myuser' resolved the issue but would be helpful to update the script to avoid confusion.

slimmingworlduk commented Oct 30, 2017

We found the issue was with the script creating the SQL logins. We chose a hyphenated username eg, 'my-user'. The current script will crash in this case as the [] are missing from the create statement. Updating to use 'myuser' resolved the issue but would be helpful to update the script to avoid confusion.

@patrickebates

This comment has been minimized.

Show comment
Hide comment
@patrickebates

patrickebates Oct 30, 2017

Member

I can look into forwarding this info to the MS Slingshot team, but I believe even they are at the mercy of the APIs provided by Azure Operations.

Member

patrickebates commented Oct 30, 2017

I can look into forwarding this info to the MS Slingshot team, but I believe even they are at the mercy of the APIs provided by Azure Operations.

@slimmingworlduk

This comment has been minimized.

Show comment
Hide comment
@slimmingworlduk

slimmingworlduk Oct 31, 2017

The issue seems to come from the deployment package PNGallery142.zip which contains two sql scripts to create the logins/users. So the statement below fails if the user specified in the template is hyphenated:

CREATE USER PlaceHolderForUser FOR LOGIN PlaceHolderForUser;

to fix [] should be added

CREATE USER [PlaceHolderForUser] FOR LOGIN [PlaceHolderForUser];

slimmingworlduk commented Oct 31, 2017

The issue seems to come from the deployment package PNGallery142.zip which contains two sql scripts to create the logins/users. So the statement below fails if the user specified in the template is hyphenated:

CREATE USER PlaceHolderForUser FOR LOGIN PlaceHolderForUser;

to fix [] should be added

CREATE USER [PlaceHolderForUser] FOR LOGIN [PlaceHolderForUser];

@patrickebates

This comment has been minimized.

Show comment
Hide comment
@patrickebates

patrickebates Oct 31, 2017

Member

Wow, I forgot that was even there. That deployment hasn't been updated in some time because of the red tape involved, and the fact that at last update it was still using methods which pre-date Azure by about a decade.

I recommend you use the Deploy To Azure button in this GitHub repo.

Member

patrickebates commented Oct 31, 2017

Wow, I forgot that was even there. That deployment hasn't been updated in some time because of the red tape involved, and the fact that at last update it was still using methods which pre-date Azure by about a decade.

I recommend you use the Deploy To Azure button in this GitHub repo.

@slimmingworlduk

This comment has been minimized.

Show comment
Hide comment
@slimmingworlduk

slimmingworlduk Oct 31, 2017

Ahh I see, we've always deployed via the Azure market place.

slimmingworlduk commented Oct 31, 2017

Ahh I see, we've always deployed via the Azure market place.

@patrickebates

This comment has been minimized.

Show comment
Hide comment
@patrickebates

patrickebates Oct 31, 2017

Member

If you need instructions on performing a deployment directly from GitHub into a web app in an existing plan, I can point you in that direction as well. You will find it much cleaner than the marketplace option.

Member

patrickebates commented Oct 31, 2017

If you need instructions on performing a deployment directly from GitHub into a web app in an existing plan, I can point you in that direction as well. You will find it much cleaner than the marketplace option.

@joegasper

This comment has been minimized.

Show comment
Hide comment
@joegasper

joegasper Nov 8, 2017

Can you please do the pointing to deployment directly from GitHub please. Thanks.

joegasper commented Nov 8, 2017

Can you please do the pointing to deployment directly from GitHub please. Thanks.

@patrickebates

This comment has been minimized.

Show comment
Hide comment
@patrickebates

patrickebates Nov 8, 2017

Member

Here's the short version. If anyone needs more details, just ask.

Create a new Azure SQL DB in the Azure portal
Create a new (and empty) Web App in the portal. During this step, you will have the option of placing it into an existing App Service Plan as well.
Now navigate to the settings for your Web App.
Under 'Application Settings' set at least PHP 7.0
Under 'Deployment Options' make the following selections...

Source - External Repository
Repository URL - https://github.com/ProjectNami/projectnami
Branch - Latest
Repository Type - Git

Save those settings, and Azure will clone the branch into your Web App over a couple of minutes.

Navigate to the public URL of the Web App and perform WordPress setup

Later when you need to update to newer versions, return to 'Deployment Options' in the Azure portal and click the Sync button at the top.

Member

patrickebates commented Nov 8, 2017

Here's the short version. If anyone needs more details, just ask.

Create a new Azure SQL DB in the Azure portal
Create a new (and empty) Web App in the portal. During this step, you will have the option of placing it into an existing App Service Plan as well.
Now navigate to the settings for your Web App.
Under 'Application Settings' set at least PHP 7.0
Under 'Deployment Options' make the following selections...

Source - External Repository
Repository URL - https://github.com/ProjectNami/projectnami
Branch - Latest
Repository Type - Git

Save those settings, and Azure will clone the branch into your Web App over a couple of minutes.

Navigate to the public URL of the Web App and perform WordPress setup

Later when you need to update to newer versions, return to 'Deployment Options' in the Azure portal and click the Sync button at the top.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment