I'm trying to build a webservice/backend for a new mobile app I'm building usuing Xamarin Forms and Azure Services. I've been following this tutorial.
Everything is fine until I get to the section for "Deploy the project to Azure App Service", where I have 2 related issues. I get this same issue with my own DataObjects AND with the standard "ToDoList" application that is given as an example.
When I go to publish the first time, I select "Update database" on the "Settings" tab in the Publish Wizard in order to push my new DataObjects/Schema through to my new database. Then, I hit publish, and I get an error back saying System.Data.SqlClient.SqlException (0x80131904): Cannot attach the file '{LocalFilePath}\App_Data\{databaseName}.mdf' as database '{databaseName}'. I notice that there is NOTHING in the specified "App_Data" folder, is it possible that I need to do something to build the .mdf prior to publishing to the app service?
After this error occurs, and I try to re-publish the database, and the Publish Wizard has 2 differences. First, I no longer have the "Update Database" option, I only have the "Execute Code First Migrations" option on the Settings Tab, and it is grayed out. Second, the Preview tab says "No databases are selected to publish"
I've tried to publish the database through the App Service three different ways, and each of them is giving me the exact same scenario described above, so I think I'm just missing something obvious since I'm new to Azure and Mobile App development.
Create Mobile App Backend + Service + Database through the Azure Portal, and then deploying the "QuickStart" project from the Azure Portal.
Following a tutorial similar to the one above, but that was specifically for publishing the ToDoList database schema that is inserted by default. This was the tutorial I followed
Following the tutorial above but utilizing my own custom DataObjects rather than the ones described in the tutorial.
I've read up on ways to get the "Execute Code First Migrations" to be available, but I haven't found anything that actually allows me to deploy the database yet, as it keeps on saying "No databases are selected to publish", and I can't get the "Update Database" option to show up after that initial failure. Is there anything obvious that I'm missing?
When I go to publish the first time, I select "Update database" on the "Settings" tab in the Publish Wizard in order to push my new DataObjects/Schema through to my new database. Then, I hit publish, and I get an error back saying System.Data.SqlClient.SqlException (0x80131904): Cannot attach the file '{LocalFilePath}\App_Data{databaseName}.mdf' as database '{databaseName}'. I notice that there is NOTHING in the specified "App_Data" folder, is it possible that I need to do something to build the .mdf prior to publishing to the app service?
As official document mentioned about Update database in the Publish Web wizard as follows:
you select the check box labeled Update database in the Publish Web wizard. This check box is shown for SQL Server databases that the application accesses without using an Entity Framework Code First context class.
If your source local db is not created before you deploying your app, you would get the error as follows:
For more details, you could refer to the dbDacFx Web Deploy Provider section in this document.
After this error occurs, and I try to re-publish the database, and the Publish Wizard has 2 differences. First, I no longer have the "Update Database" option, I only have the "Execute Code First Migrations" option on the Settings Tab, and it is grayed out. Second, the Preview tab says "No databases are selected to publish"
Execute Code First Migrations (runs on application start) is shown for databases that the application accesses by using an Entity Framework Code First context class.
When you select this option, the deployment process automatically configures the application Web.config file on the destination server so that Code First uses the MigrateDatabaseToLatestVersion initializer class.
If you run the Enable-Migrations command in Package Manager Console, you could select this check box. For more details, you could refer to the Entity Framework Code First Migrations section in this document.
For a simple way, you could leverage the "QuickStart" project from the Azure Portal to migrate your db via EF code first. When deploying your project, update your local connectionstring with your target db (e.g. Azure db) connectionstring under "Settings > Databases" in the VS publish web wizard as follows:
Related
In Visual Studio 2017, I create a new Basic Azure Node.js Express 4 App. On the Project tab, I click Convert to Microsoft Azure Cloud Service project.... I do not do any further coding.
Next, in the Solution Explorer, I right-click on the thus created .Azure project and click on Publish....
After filling in my credentials for my MS account, I follow all the steps in the Microsoft Azure Publish dialog. Somewhere it says Creating New Application Insight resource, then in the status bar it say Publish started...
Then, after a short while, I get the following message:
CloudServices64: Cannot find file named 'approot\bin\setup_web.cmd' for startup task setup_web.cmd > log.txt of role ExpressApp10
Can anyone please tell me what this means and what I can do about it?
Kind regards,
John Pool
I'm using VS 2013 and SDK 2.2 to deploy to App Services, the site opens in it's address and show the message "This web app has been successfully created".
Like when there is no code in the cloud app. although I can enter the App Service Editor, and see the code is there.
Localy I run the site and it show the Home/index page, but not in the cloud.
It was fine before, until I remove the web project and created another one with the same name instead.
Hope all this clause help to solve..
Since I try to redeploy, the SDK assumed some files are already exists and did not reload them.
They were probably corrupted.
The solution was to delete the complete deplyment, the wwroot directory and redeploy.
In publishing a Lightswitch app to Azure (for the first time) I get to the Service Configuration line and the "Select a web site to host your application". I have created the website on Azure as well as a SQL database and linked them. I have download the Pay-As-You-Go-Free Trial-5-10-2014-credentials.publishsettings file and imported it numerous times, hit the refresh button--everything. The Security Settings and Data Connections are all ok. My only guess is that there is a corrupt file that needs to be deleted but I really cannot guess anymore about what has gone wrong.
The only thing that comes up in the "Select a web site to host your application: dropdown is ". Prehaps I missing some setup step on the Azure portal. I don't know.
Found the work around on these links in the Microsoft forums.
http://social.msdn.microsoft.com/Forums/vstudio/en-US/4f31d311-dfc2-47ac-80e1-64af0487717e/cant-publish-vs2013-ls-project-this-subscription-has-no-web-sites?forum=lightswitch
http://blogs.msdn.com/b/david_kidder/archive/2013/07/19/publish-lightswitch-2013-preview-applications-to-windows-azure-web-sites-without-the-azure-sdk.aspx
This should be simple..
I have done this.
Create default MVC 4 template and publish site to Azure web site. No problem.
Create a Contact model
Create a view/controller and for the model. Now basic CRUD works on the site with the localDB
Enable migrations, add migration, create test data in seed and update migration. Everything works locally. great!
Now how do I get that database into SQL Azure? I thought it was..
Publish and set ContactContext to SQL Azure string. Test connection. Works. Check 'Use this connection at runtime' .( I assume that means when it is copied it will use that connection).. So now I publish.. then goto /Contacts ... it should automatically create the new DB in Azure... but instead I get
Invalid object name 'dbo.Contacts'.
Where did I go wrong ? Is there another way.. Should I just make a script with schema and data and run that on my SQL Azure table instead? I could do that but it seems the 'publish' way would be easier..
When publishing, check your publish settings and see if it executes the code-first migrations.
This fixed it form me ;)
I want to use a separate/ named schema in an Azure WebSite app to implement a multi-tenancy in separate schemas pattern with Azure SQL. My app runs correctly in Visual Studio but not on Azure. I searched StackOverflow for similar issues, and found:
This answer suggests it can't be done: Multi-tenant application on Windows Azure. This question does not apply directly to named schemas: Azure SQL database working when ran locally but not when published to Azure.
For the MVC4 app I am developing I configured the Azure SQL database to use a named schema and modified the Connection String login name and password. When I tried to register the first user it threw the error message "Invalid object name 'UserProfile'" from Azure SQL. I checked the stack trace and everything looked reasonable so I reviewed the code for the SimpleMembershipProvider and did not see anything that should break when using a named schema.
As a Proof of Concept, I opened Visual Studio 2012 and created a new MVC4 app with .NET Framework 4.5 using the Internet Application template, which of course implements the Simple Membership Provider. I opened the Azure console and created a new web site with new database, then published the app to Azure. I ran the app and clicked the Register link to add the first user. This was successful, and I was able to logout, login, etc.
I then modified the PoC app's Azure SQL configuration by creating a new named schema, login and user. I added the db_owner role for the new user in the new database. I altered the user's default schema and transferred the tables created by the initial run into the named schema. I confirmed that the user's default schema is correct and the tables are in the named schema. I changed the user name and password in the Connection String section of the Publish dialog and again published the app from Visual Studio. I opened the website in Chrome and clicked the Register link. I entered a user name and password and got the error message "Invalid object name 'UserProfile'". I got the same error when atttempting to login with the user created in the first run.
I am looking for ideas about what to check next. I can work around this issue, but if I missed anything simple I would rather fix things the efficient way. Any ideas?
It seems I found a bug in Azure WebSites that causes the Connection String to not be updated by publishing the web site.
There is a connection string on the Azure Management portal's Configure page for the web site. This connection string is used to connect to the web site's database. It initially contains the User Id and Password used to create the database. Entering a different User ID and Password in the Visual Studio web site project (in Web.config or in the Publish Web dialog) has no effect on the connection string in Azure. This caused a problem in my specific situation, but would also be an issue for anyone who does not use the sa-like server-level user for accessing the database from the web site.
The workaround I found for this issue is to directly modify the Connection String in Azure on the web site's Configure page, instead of relying on effectiveness of a change in the Visual Studio project. This resolved the problem and now the named schema is working correctly.