Talk to a SQL Database in Azure Gov from a Teams chat: Using Teams & Flow in the Government Cloud

Published 08-27-2019 07:00 AM 2,888 Views
Microsoft

Bot integration in Teams isn't available yet in the Government Cloud [as of this writing], but we can still 'talk' to other systems (like a SQL database) using Flow. Let's consider the scenario where my friend Tony Stark and I are both a part of the Department of Transportation, and we're tracking the number of potholes on streets throughout the State. Tony decides to track and store the pothole data in a cloud-based SQL database that he has created in our Azure Government tenant. I'm a project manager who wants to query this data from my Teams environment, without special tools or having to understand database queries. Let's look at one approach.

 

First, let's see how Tony has created the database. Using Azure, he creates a small and simple SQL Database table called pothole1:

 

0.pngThis database stores street names and the number of potholes on that street...

0 (7).png

 

Now that the database is created and being populated with data, let's see how Flow can help me see that data in Teams. We've created a Channel in Teams to be used specifically for 'talking' to the data - in this scenario, whenever someone posts the name of a known street name in the Channel, Flow will respond with an automated post showing the number of potholes on that street by querying the SQL database. Our end result will look something like this:

 

0 (6).png

 

To do this, Flow will look for any post in this Channel, and use the content of the post as an input in a SQL query. The entire Flow looks like this:

 
0 (5).png

 

If we break it down, we'll see that we need to use the Compose action to get output (like the Msg ID and the result of our SQL query) that we'll need at the end of our Flow. But the key action is our SQL query action, which contains our query:

 

0 (4).png

 

However, this only works with the right connection information. Flow is able to create a connection to our SQL Database using its Connections capability:

 

0 (3).png

Finally, we post our automated Teams response message by using the original Msg ID (so we know which conversation to Reply to) and the [unformatted] response from our SQL query, both of which were exposed for us by the Compose action:

 

0 (2).png

 

The result is a Channel that anyone in our Team can use to "ask the database" about the current number of potholes for a given street:

 

0 (1).png

 

With this functionality now in place, our admin Tony Stark can spend less time fielding email requests re: pothole data, and more time... fighting bad guys? :)

 

For more articles in this series, follow #TeamsFlowInGCC in Linked or Twitter, or view this series in the Public Sector TechCommunity Blog.

 

%3CLINGO-SUB%20id%3D%22lingo-sub-810047%22%20slang%3D%22en-US%22%3ETalk%20to%20a%20SQL%20Database%20in%20Azure%20Gov%20from%20a%20Teams%20chat%3A%20Using%20Teams%20%26amp%3B%20Flow%20in%20the%20Government%20Cloud%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-810047%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fmicrosoftteams%2Fplatform%2Fconcepts%2Fbots%2Fbots-overview%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EBot%20integration%3C%2FA%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Ein%20Teams%20isn't%20available%20yet%20in%20the%20Government%20Cloud%20%5Bas%20of%20this%20writing%5D%2C%20but%20we%20can%20still%20'talk'%20to%20other%20systems%20(like%20a%20SQL%20database)%20using%20Flow.%20Let's%20consider%20the%20scenario%20where%20my%20friend%20Tony%20Stark%20and%20I%20are%20both%20a%20part%20of%20the%20Department%20of%20Transportation%2C%20and%20we're%20tracking%20the%20number%20of%20potholes%20on%20streets%20throughout%20the%20State.%20Tony%20decides%20to%20track%20and%20store%20the%20pothole%20data%20in%20a%20cloud-based%20SQL%20database%20that%20he%20has%20created%20in%20our%20Azure%20Government%20tenant.%20I'm%20a%20project%20manager%20who%20wants%20to%20query%20this%20data%20from%20my%20Teams%20environment%2C%20without%20special%20tools%20or%20having%20to%20understand%20database%20queries.%20Let's%20look%20at%20one%20approach.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFirst%2C%20let's%20see%20how%20Tony%20has%20created%20the%20database.%20Using%20Azure%2C%20he%20creates%20a%20small%20and%20simple%20SQL%20Database%20table%20called%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CEM%3Epothole1%3C%2FEM%3E%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20394px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F126605i7E11C1AE87E47898%2Fimage-dimensions%2F394x257%3Fv%3D1.0%22%20width%3D%22394%22%20height%3D%22257%22%20alt%3D%220.png%22%20title%3D%220.png%22%20%2F%3E%3C%2FSPAN%3E%3CSPAN%3EThis%20database%20stores%20street%20names%20and%20the%20number%20of%20potholes%20on%20that%20street...%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20777px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F127398i56C7B1091D4F75A9%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%220%20(7).png%22%20title%3D%220%20(7).png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ENow%20that%20the%20database%20is%20created%20and%20being%20populated%20with%20data%2C%20let's%20see%20how%20Flow%20can%20help%20me%20see%20that%20data%20in%20Teams.%20We've%20created%20a%20Channel%20in%20Teams%20to%20be%20used%20specifically%20for%20'talking'%20to%20the%20data%20-%20in%20this%20scenario%2C%20whenever%20someone%20posts%20the%20name%20of%20a%20known%20street%20name%20in%20the%20Channel%2C%20Flow%20will%20respond%20with%20an%20automated%20post%20showing%20the%20number%20of%20potholes%20on%20that%20street%20by%20querying%20the%20SQL%20database.%20Our%20end%20result%20will%20look%20something%20like%20this%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CDIV%20class%3D%22slate-resizable-image-embed%20slate-image-embed__resize-full-width%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F127397iED7532417B9A233D%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%220%20(6).png%22%20title%3D%220%20(6).png%22%20%2F%3E%3C%2FSPAN%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3C%2FDIV%3E%0A%3CP%3ETo%20do%20this%2C%20Flow%20will%20look%20for%20any%20post%20in%20this%20Channel%2C%20and%20use%20the%20content%20of%20the%20post%20as%20an%20input%20in%20a%20SQL%20query.%20The%20entire%20Flow%20looks%20like%20this%3A%3C%2FP%3E%0A%3CDIV%20class%3D%22slate-resizable-image-embed%20slate-image-embed__resize-full-width%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CDIV%20class%3D%22slate-resizable-image-embed%20slate-image-embed__resize-full-width%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F127396i1457D3A3B83AE5CF%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20alt%3D%220%20(5).png%22%20title%3D%220%20(5).png%22%20%2F%3E%3C%2FSPAN%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3C%2FDIV%3E%0A%3CP%3EIf%20we%20break%20it%20down%2C%20we'll%20see%20that%20we%20need%20to%20use%20the%20Compose%20action%20to%20get%20output%20(like%20the%20Msg%20ID%20and%20the%20result%20of%20our%20SQL%20query)%20that%20we'll%20need%20at%20the%20end%20of%20our%20Flow.%20But%20the%20key%20action%20is%20our%20SQL%20query%20action%2C%20which%20contains%20our%20query%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CDIV%20class%3D%22slate-resizable-image-embed%20slate-image-embed__resize-full-width%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F127395i2AD1C897774D4C28%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20alt%3D%220%20(4).png%22%20title%3D%220%20(4).png%22%20%2F%3E%3C%2FSPAN%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3C%2FDIV%3E%0A%3CP%3EHowever%2C%20this%20only%20works%20with%20the%20right%20connection%20information.%20Flow%20is%20able%20to%20create%20a%20connection%20to%20our%20SQL%20Database%20using%20its%20Connections%20capability%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F127394i8619ACD1D8FEA33C%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%220%20(3).png%22%20title%3D%220%20(3).png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EFinally%2C%20we%20post%20our%20automated%20Teams%20response%20message%20by%20using%20the%20original%20Msg%20ID%20(so%20we%20know%20which%20conversation%20to%20Reply%20to)%20and%20the%20%5Bunformatted%5D%20response%20from%20our%20SQL%20query%2C%20both%20of%20which%20were%20exposed%20for%20us%20by%20the%20Compose%20action%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F127393i9445B3A744DE096D%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20alt%3D%220%20(2).png%22%20title%3D%220%20(2).png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20result%20is%20a%20Channel%20that%20anyone%20in%20our%20Team%20can%20use%20to%20%22ask%20the%20database%22%20about%20the%20current%20number%20of%20potholes%20for%20a%20given%20street%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F127392iD2B819134138746F%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20alt%3D%220%20(1).png%22%20title%3D%220%20(1).png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CDIV%20class%3D%22slate-resizable-image-embed%20slate-image-embed__resize-middle%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3EWith%20this%20functionality%20now%20in%20place%2C%20our%20admin%20Tony%20Stark%20can%20spend%20less%20time%20fielding%20email%20requests%20re%3A%20pothole%20data%2C%20and%20more%20time...%20fighting%20bad%20guys%3F%20%3A)%3C%2Fimg%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFor%20more%20articles%20in%20this%20series%2C%20follow%20%23TeamsFlowInGCC%20in%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fwww.linkedin.com%2Ffeed%2Fhashtag%2Fteamsflowingcc%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3ELinked%3C%2FA%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eor%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Ftwitter.com%2Fsearch%3Fq%3D%2523teamsflowingcc%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%20data-artdeco-is-focused%3D%22true%22%3ETwitter%3C%2FA%3E%2C%20or%20view%20this%20series%20in%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2FPublic-Sector-Blog%2Fbg-p%2FPublicSectorBlog%22%20target%3D%22_blank%22%3EPublic%20Sector%20TechCommunity%20Blog.%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-810047%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F127399i9DC2539D2F0F6523%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20alt%3D%22using%20teams%20and%20flow.jpg%22%20title%3D%22using%20teams%20and%20flow.jpg%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EBot%20integration%20in%20Teams%20isn't%20available%20yet%20in%20the%20Government%20Cloud%20%5Bas%20of%20this%20writing%5D%2C%20but%20we%20can%20still%20'talk'%20to%20other%20systems%20(like%20a%20SQL%20database)%20using%20Flow.%26nbsp%3B%20I%3CSPAN%3En%20this%20scenario%2C%20whenever%20someone%20posts%20in%20the%20Channel%2C%20Flow%20will%20respond%20with%20an%20automated%20post%20after%20querying%20the%20SQL%20database.%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-810047%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EPublic%20sector%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Version history
Last update:
‎Aug 26 2019 09:28 AM
Updated by: