I am very new to Windows Azure and am tinkering with it to learn how it works. To keep things as simple as possible, I am trying to deploy the default MVC 4 template that is generated by VS 2012 Express for web. I created a new project - an Azure cloud service. I selected an MVC 4 web role. And that creates a nice little asp.net application with home, about and contact pages, and links to register and login. I just want to deploy this site to Azure and see it work on the cloud.
However the membership does not appear to work on azure. The pages of the application appear correct. However when I click the 'Register' link it does not take me to a page to nter a new username and password. I do not believe the membership tables are being generated anywhere either.
Considering how simple this is, I think I must be making a silly mistake somewhere. I would really appreciate if someone could help me with this.
Also, for the record, I have noticed that if I create a stand alone MVC 4 project in VS2012 Express (as opposed to a Windows Azure Cloud service project with an mvc 4 web role) then when I right click that MVC4 project and choose to publish it, it allows me to specify a sql database using a connection string. What is more is once it is published to Azure, the membership works perfectly. I can create useraccounts and log in. If I examine my SQL Azure database using the azure portal, I can see the new membership tables created there.
But when I try to publish a Windows Azure Cloud service with MVC4 webrole, I do not see any option to provide a connection string of any sort to the azure project. Maybe that is why the membership is not working... since there is no database linked with the web role... but I cannot figure out how to specify this. I was under the impression that publishing a stand alone MVC4 project to Azure, and publishing an Azure Cloud Service with an MVC4 Web Role is the exact same thing, please correct me if I am wrong. And either way, I should be able to see the membership functionality of my mvc 4 web role.
Here are the steps to recreate what I have. Basically it is all default stuff:
Create a new project in VS2012 Express
File -> New Project -> 'Windows Azure Cloud Service'.
On the next screen add an ASP.NET MVC 4 Web Role to it.
On the subsequent screen choose 'Internet Application'.
These 3 steps create a new project. It runs locally just fine.
Now I try to put it on the cloud.
Right click on the windows azure project in solution explorer and choose 'Publish'.
Choose the subscription (I already have certificate/credentials in place to publish to azure from VS so I select that)
Create a cloud service on the next screen (I name it 'garyazurecloudservice').
Accept all the default settings in the Publish wizard and click Publish.
The publishing process takes a few minutes.
The web application can be viewed at http://garyazurecloudservice.cloudapp.net/.
The Home, About and Contact pages all display correctly. However it I click the 'Register' link at the top right I see a webpage with the correct layout template, but an error in red that says:
"Error. An error occurred while processing your request."
I have tried to create an SQL database on Azure but I don't see any way to connect this role to it. Possibly that is the problem? Or maybe it is something else altogether. I would appreciate if anyone can tell me what is wrong.
I have spent the entire day googling and going in circles with no success. Thank you for any help you can provide.
Gary
You're right in that the Membership section of your website would not be able to create the SQL tables in the background when running on Azure, due only the problem of where those tables would reside.
Remember, that Azure hosting space is different from traditional hosting, in that your site would exist on a virtual machine, with files being replicated to another virtual machine if the first were to experience problems. Also, what would happen if you were to invoke a second 'server' to host your website, to cater for a load, perhaps? Where would the tables live then, and how would the second virtual machine know how to access the first?
The answer would be to create a SQL Azure database, upload your tables there, and then you'd have a permanent place for 1, 2 or 1000 'servers' that are running your website to access a central database repository of your data.
I know in your example, it should just 'work' and I agree to some extent, but your application running on your local machine or with your existing (traditional) web host is quite different to the Azure model of working.
In terms of your question regarding how the SQL Azure set-up works, presumably you've created this through the Portal, via the www.windowsazure.com website? If so, then you should be able to see and manage your SQL Azure database from there, including gaining access to the Connection Strings section, whereby you would copy and paste these into your web.config file for your MVC4 application. From there, you can utilise this database pretty much as though you would any other.
I hope this all helps - Azure is a beautiful beast once tamed.
Related
I have to migrate asp.net webform & asp.net MVC websites to Microsoft Azure and most of the webform based website have been created as "website project" in visual studio. and all website use MS SQL Server 2008 R2 as database plus all website use either .net Framework 4.0/4.5.
I confused by reading article regarding migrating webform based website to Azure not working and need code changes and if we use Azure database then we cant use stored procedures etc... this has confused me alot.
So i have few question regarding this.
Can i move asp.net webform 4.0 based website directly to Azure without making any code changes assuming we are connecting to external SQL SERVER 2008.
For first step can which MS SQL Server database i need to choose on Azure so that i can easily restore database in Azure and connect to this database from my local machine using MS Management Studio..
I have heard lot about Azure store files as blob and we need to make change to code to point to new path. What is this Azure blob and why do we need to change code for pointing them blob.
What i have to do keep allowing users from uploading images & document without making any changes in the code..
Does Azure website have always 1 instance running or multiple instance running, i am asking this as our website use InProc session state will i lose session if it is ruuning on multiple instance. or should we prefer SQL Session state in Azure enviroment.
What i should take into consideration for migration current website to Azure.
Will copy pasting all the files in Azure work. Please advise
Depending on how old the ASP.NET webforms projects are, you are going to need to bring them up to date with current security, and anti forgery tokens, etc.
Also if the project was previously a "Website" and not a "Web Application", this is also something that you will need to take into consideration!
I am currently working on upgrading a website to a web application.
This might be a useful website to look through
http://www.gregthatcher.com/Azure/Ch7_ConvertWebsiteToWebApplication.aspx
Migrating to Azure is easy ,
create a Azure account and create the web app which you want to host or create.
you can deploy using FTP or use the build and deploy feature in TFS account.
Steps
You need to create web app in your account.
create a DB in azure manually or export your DB to azure from Management studio if you have an existing DB
get the Connection string from the Publish profile from Azure.
Setup the storage account if you want to store files ,images etc.
I been following a Microsoft tutorial on Azure Web Apps:
https://azure.microsoft.com/en-us/documentation/articles/web-sites-dotnet-deploy-aspnet-webforms-app-membership-oauth-sql-database/
I created a Web App on Azure then created the website in VS 2013 on my PC with authentication all working. I then tried to publish the website onto Azure. When I go through the publishing steps, I do not get a connection string. I have tried waiting (24 hours) and looked around the app to see if there are any settings, but I cannot find a way to get a connections string. Everything other than the login-in works.
I know I selected a free 20Mb database, but I cannot see any sign of one on the Azure portal. I created a second Azure Web app and it is exactly the same.
Where would I find the Azure app database (in the Azure Portal) used for storing the username & password? Any idea how I can get the login to work in the Azure cloud?
So long you shouldn't have to wait. I just tried it and had the free DB after two minutes.
You find all SQL Server databases incl. the free one in the SQL Server section. That's the icon on the left with the container and the "DB" in front. There you should find your new database. Click on it, switch to the dashboard and on the right you find the section "quick glance". Click on the link "Show connection string" and copy from there what you need.
Btw, you should not be able to create a second free SQL DB. If you're allowed to create "second" free SQL DB, than there is no first one. That would definitely mean there went something wrong in the first place.
While creating the website you would have specified the database server, db name etc. Under the sql db section this db will be listed. If you have done that way. then migrate the db that you have locally to azure using the migration wizard and then provide that azure sql db connection string in the web.config ( from where the connectionstring is used.) then the application should work fine.
I been developing a website with MVC3/EFCode First/C#, everything ok, I tested multiple times on my computer and all perfect.
I used ASP.NET membership to manage permissions, and the administration web that provides Visual Studio 2010 (the little button on the Solution Explorer with a Hammer and a Little World), that launch a website where i can add more users, roles, and some configurations. I used the feature that enables you to add users, to add an "admin user" to the platform that create all the other users... but i NEED this first user on my membership table (so i can log-in and create all the stuff that the website use).
The trouble that I have is that I hosted the website on Godaddy using the publish tool on Visual Studio, everything ok, I create the database and the connection strings are ok, but I don't have this "Control Panel" to add the first user...
What can I do?
You have added the structure of the database to your remote server. Now you need to add the contents of your Asp.Net membership tables to the GoDaddy copy as well.
For example, see this: http://msdn.microsoft.com/en-us/library/dd394698.aspx, and you can find
Database deployment settings for deploying to staging servers and production servers are like the settings that you entered for the Debug build configuration. The difference is that you do not want to deploy the test user accounts that you entered into the ASP.NET membership system. However, you cannot just specify Schema Only database deployment for the ASP.NET membership database. This is because one of the tables in the database contains configuration data that is required for the ASP.NET membership system. Therefore, you will create a custom script to add the configuration data.
At this location
I am developing an online internal web portal (like users write tests, provide document links to study, completing a study roadmap, admin user to view ststistics, etc). It caters some 150 users. I have planned to use ASP .NET with c# in Visual Studio 2008 on windows xp. I am implementing using Forms and NOT MVC since I feel at home with forms.
I do not want to use windows authentication since each user will have many attributes related to him and so it will be easy using a database. Security is not an issue since it is being used internally only.
I have only a fair knowledge about ASP and C# and VS 2008.
Now my questions:
Can I use MS SQL server database that is built in in VS 2008?( I cannot ask for external databases)
Can I export the website totally along with the databases to IIS server running in some other computer? How?
Do I need to export databases separately or provide a database creation script like PHP?
(I have more questions. Will update once I start off).
(This is my first .net web app. so can i know where i can find login scripts, pagination, examples, and pretty much all the stuff)
edit: which to use? New website or New Webapplication?
You can pretty much use any database, but it seems from your requirements that you want to look closer towards something like SQLExpress, SQL Server Compact Edition or SQLLite.
Can I export the website totally along
with the databases to IIS server
running in some other computer? How?
Your database will be shipped along with your application if you use one of the database options that I have specified above.
Do I need to export databases
separately or provide a database
creation script like PHP?
See my comment above, the database will exist when you deploy your website to IIS. It's a physical file that will be in your APP_DATA folder.
You can use:
MySQL. The reason: It has no space or memory limit!
SQL Server or SQL CE. These are both alike. They just differ in slite functions, and also the storage!
The SQL CE allows you to have 4GB. But the SQL Server lets you have 10GB.
So it depends on your work!
Also, I wanted to point out one error in a post, that the SQL CE is present in App_Data, Correct! But the SQL Server is placed somewhere like:
C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\here_will_it_be
And yes, you can migrate it to wherever you want to place it. I mean if you want to upload it to a hosting server, you can upload it using Web Deploy! Or what ever service. When downloading you will have to repeat same process!
I hope you are doing good with your first web app! :)
My Problem is the following,
I have an ASP.Net web site hosted on IIS. This web site connects to an Access 2007 DB file on the same server. The DB file contains links to sharepoint lists on another server on the same domain. If I run the web site on the visual studio built-in server, I can Open connection to the DB file and retrieve data just fine. But whenever I try to run the web site over the IIS, the web site can't open a connection with the DB file.
What do you think the problem is?
Thanks.
It will be a permissions problem. When you run with Visual Studio's web server it is running as you, IIS on the other hand runs (by default) as Network Service. This is limited in what it can do.
To access an access database (no pun intended) the account that IIS runs under will need the ability to read, write, execute, change and delete for the directory the database is in. By default this should be granted to the APP_DATA directory, if your access database is elsewhere you will need to grant these permissions.
Connecting via Access to a remote machine is a whole other problem, it's unlikely this will work because the Network Service account is a local account and will not exist on the sharepoint server, and you cannot grant access because it does not exist.
If you were in a domain you could run IIS under a suitable locked down domain account and it might work, but frankly it's all a bit messy!
Have a look at this article:
How to connect to a remote Access database from Active Server Pages
http://support.microsoft.com/kb/253580
Yes, I know your database is on the same machine, but there are differences in permissions and authentication for files and folders when you run IIS. The chances are good that whatever is hanging you up is covered in this article.
Whether mixing Access databases and IIS is a Good Thing or not is a separate discussion...
Access 2007 makes connecting to SharePoint a breeze. After you link to a list, then ADO, and even DAO + VBA code and your sql queries work on those lists!
I seen a good number of people thus start using the JET (actually it called ACE in access 2007) as a data connector to SharePoint for this very reason. Since your are building a web based system then we not using ms-access here, but ONLY using the 2007 version of the JET data engine that ships with access 2007.
Someone does need to come out with a OLEDB provider for SharePoint lists that allows ones web site or .net code to view those lists as standard sql tables like ms-access can. Using JET as the data connector system is likely not such a good idea. I do realize that you not storing nor placing data in the access JET table, but are using the wonderful ability of the new access JET engine to view and use SharePoint lists as regular sql tables. This approach does allow your ASP.net code to execute sql updates on that data or do whatever as if this was a regular sql table. It does make this oh so easy.
The security permissions on the SharePoint site are thus going to view this connection as not as a end user, but always see the USER as the actual web site connecting (or at least the user you were in ms-access when you linked the table to SharePoint). I don’t believe the SharePoint user authentication process can work reliable when you do this. What will happen is you change a few things on the SharePoint site, and next thing you know the JET connection will be trying to prompt you for new logon credentials. You can’t provide nor control those logon credentials at that point in time.
So, as others pointed out, this is going to be problematic and not reliable.
Using Access as a fudge to access SharePoint from an ASP.net site is going to give you lots of pain in the long run.
A much better way would be to use SharePoint's web services to access that data - removing Access from the equation altogether.
http://www.scribd.com/doc/8634090/Accessing-SharePoint-Data-Using-C-Without-Running-Code-On-the-SharePoint-Server-Part-1
MSDN - Using ASP.NET web services
Creating and Consuming a Web Service