So we now have this very cool LightSwitch HTML app, with new Security Management and Tile screens. So big question is, how do we get this deployed and working successfully in the cloud. Well quite simple really. We’ll use Microsoft Azure as our provider for this section. Other providers won’t be much different than how you normally deploy. You do need to at least read this section as I show you how to deploy so the Security Management works.
Expectation is that you have an Azure account already or you’ll get a trial.
- Log into your Azure Portal
- Provision a new website with a database
- Grab the connection strings that are provided
- Now lets go to our solution in Visual Studio
- Change your Solution Configuration to Release
- Right click on your database project, properties
- Change the Target platform to be Windows Azure SQL Database
- Also, load up your PostDeployment1.sql script
- Now go ahead and do a fresh build
- Make sure you have your SecurityAdmin setup in your Web.config
- Right click on your LsCoreProject
- Select Publish
- In the Wizard
- Application type: Complete Application
- Application Server Configuration: Windows Azure
- Subscription: Select your subscription
Quick note, Azure and Visual Studio seem to have issues at times. If you get an Unhandled Exception of type ‘System.InvalidOperationException’, it is not the end of the world. Close the exception. Open up, in Visual Studio, the Server Explorer. Expand Windows Azure, then expand Web Sites. You’ll be prompted to Log in. Enter your credentials and log in. Issue resolved. Restart your publish process.
- Service Type: Web Site
- Service Configuration, URL: lscoreprojectdemo
- Security Settings, Administrator: Configure to your liking
- Security Settings, HTTPS: Your preference
- Data Connections, Database conx: Should prepopulate
- Data Connections, Attached Sources: Here is the secret sauce!
- Assumptions are you are still using the same Admin security account
- If not scroll the text in the input box and change them. These credentials are not SQL credentials, but the Security Administrator account within your LightSwitch application.
- Remember we used as an example User: LeaveMeAlone
- You also need to remove the localhost:{port} and use your Azure URL
- Once you’ve done that, move to the summary
- Press publish and wait for the magic!
Not to bad eh?
Now load up your application with your Azure URL
Go ahead and login with your LightSwitch Security Administration account credentials or register a new accountDidn’t work?
Azure has been flakey with LightSwitch apps. I have found that it does not seem to install the default Security Administration user that you predefined for deployment. That is until you create some other account. This is where the self register page takes care of this. Go ahead and navigate to /register.aspx of your URL and register yourself. As you see you will only get the one tile. That’s good. Security is working. Go ahead and log out and log back in now with the LightSwitch Security Administration account you had setup pre-deployment. You should see the Admin tile now. That’s good. Go ahead and create your accounts, etc. as needed. I have also seen this issue happen on standard IIS deployments. Why… Good question.
Next… Lets wrap it up
Here are the topics and their logical order:
- Create the project
- Add external CSS
- Add external scripts
- Update the default.htm
- Add LogIn/LogOut/Register/ChangePassword
- Create the security data source
- Screens for permissions
- Screens for role management
- Screens for user management
- Tables for tile menus
- Screens for icon management
- Screens for menu management
- Create a tile menu screen
- Create a database project
- — You
- Wrap up
Hi, thank you very much for this whole tutorial, it was very helpful !
However, I’ve now published the application successfully but I’m having trouble using it.
When I load the azure url in my browser, the page shows the azure default “this web app has been successfully created”, and when I enter [myurl]/register.aspx I get this runtime error:
Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.
Did I miss a step or configure something wrong ?
Thank you!
When you go to production.
Hi,
Hopefully you can help. I’ve deployed to Azure but when accessing the security entities it returns an error. Value cannot be null. Parameter name: uriString
I can hit the service directly through the browser after logging in and it will return the list of entities.
–
Default
-Permissions
… etc
However, when I try to access a specific collection (/formsSecurityData.svc/Permissions) it returns the above error.
I’m using the LsWires version before the latest release.
any ideas ?
thanks,
Miles
You need to use the microsoft service vs the formsData.svc