Hi All,
In Jan 2020 SQL PASS Meetup I spoke on how to use Power Apps with data in Azure SQL Server.
SQL Meetup link
Slide Deck for how to use Power Apps with Azure SQL Server.
These are the step by step for this blog post.
I will split into 4 parts.
In Jan 2020 SQL PASS Meetup I spoke on how to use Power Apps with data in Azure SQL Server.
SQL Meetup link
Slide Deck for how to use Power Apps with Azure SQL Server.
These are the step by step for this blog post.
Business Requirements
- Contoso Purchased Microsoft 365 subscription and has corporate Data on Azure SQL Server
Problem Statement - Staff needs to access the data using their mobile devices
- They should be able to perform in a quick UI for
- Creation
- Reading
- Updating
- Deleting (CRUD )
I will split into 4 parts.
- Set up Azure SQL Server DB
- Choose SQL Server Tables within Power Apps
- Creating PowerApps and SQL Server App
- Final touch-ups on Power Apps
- Set up Azure SQL Server DB
- Refer to how to Microsoft documentation Create a new Azure SQL Server Database.
- I will provide screenshots for this setup
Create SQL Server Database - The firewall rules have to be added so that we communicate with SQL Server Management Studio (SSMS) and also for Power App that will use in the next steps.
Azure SQL Server Firewall Rules - Connect SSMS locally and enter your Azure SQL Server credentials
- In our example, we are using 2 tables
First is Projects table and ProjectType table as shown - The Projects table has a foreign key reference to the ProjectType table.
2. Choose SQL Server Tables within Power Apps
- Go to make.PowerApps.com site.
- Start with Data and we will use SQL as our data source.
- LICENSING for Power Apps
I am using Office 365 E3 license and Power Apps comes with this license. However, integrating with Azure SQL Server, Cosmos DB, you need Power Apps P1 / P2 license.
I am using Power Apps P1 30 days trail.
Office 365 with Power Apps license comes with standard connectors such as SharePoint Online, Excel, Onedrive
You can refer to Power Apps pricing on Microsoft Site. (as of 01 Feb 2020)
3. Creating PowerApps and SQL Server App
- Power Apps have many in-built connectors and we will use SQL Server. Use SQL Server Authentication and use the same credentials that we did for connecting to SSMS.
NOTE: Must add PowerApps client IP and add to Azure SQL Server. - We can rename the default controls that are more meaningful for the user.
For e.g. instead of [dbo].[Project] label you can rename it to more meaningful such as Project Lists.
- Copy the Text and paste on Tooltip textbox.
-
You no need to publish the app as we need to make some changes.
NOTE: Save Power Apps for the first time otherwise you might lose your changes. - There are 2 issues.
- a) It has data quality issue as the user can add any number for ProjectTypeID.b) The User should be to view the Project Type and not the Project Type ID.
- To achieve this in our Power Apps design, we have to add the Project Type table in our app and user Power Apps functions
- Details screen - ProjectTypeID
End User does not know the project ID and they should be knowing the project name instead. However, our current Edit screen’s ProjectTypeID is a text field and we need to change the app to change the text field to a dropdown list. In the Detail screen, we need to change the Project Name, which is in the ProjectType table in Azure SQL Server.
- Select the ProtectTypeID Card (03), The text field i.e. Parent.Default (4) can’t be edited in the above screenshot. Therefore, select the unlock the change properties under the advanced tab (5).
- We will use Lookup function as follows:
LookUp('[dbo].[ProjectType]', ProjectTypeID = ThisItem.ProjectTypeID, ProjectTypeName)
The project system ProjectTypeID = ThisItem.ProjectTypeID is similar a join in T-SQL.
- Change ProjectTypeID field as a dropdown field
4. Final touch-ups on Power Apps
- The current app for the ProjectTypeID a dropdown list (for e.g. Translation Services value) is not editing/updating for the user.Go to Edit Screen
Let’s look at the ProjectTypeID_DataCard3 value and in Update properties, it showing up DataCardValue9.Selectected.Value which is incorrect and getting a red icon on this datacardThe reason for that we stored ProjectTypeIDs in our project table. Let's make a minor change to DataCardValue9.Selected.ProjectID as shown
I hope this Power Apps tutorial helped you.
--Aroh
No comments:
Post a Comment