Professional Documents
Culture Documents
Search
Listen Share
One of the most powerful cloud SaaS suites at the moment is Microsoft Azure. It
provides:
• Databases
• Kubernetes
• Mobile apps
• VPNs
• File storage
• Machine learning
1 of 22 2/6/2024, 12:52 PM
How to connect an Azure database to third-party services |... https://medium.com/@dmobjects/how-to-connect-an-azu...
It’s incredible, actually. I could go on all day about the plethora of things that
Microsoft knows that are of great value for the future of software development.
But, because attention span is limited I’ll go ahead and teach you how to connect
an Azure database to ASP.NET, Python, Power BI, and SQL Server Management
Studio.
We’ll go from creating a free trial account on Azure all the way towards
connecting our database and performing a query.
• 12 months of access
• 30 days of service
• $200 credit
Keep in mind that all your testing should take place within the 30-day period.
After that, your data will remain read-only and you’ll need to upgrade to keep on
using Azure services as a whole. Regarding the $200 credit, that gets depleted as
2 of 22 2/6/2024, 12:52 PM
How to connect an Azure database to third-party services |... https://medium.com/@dmobjects/how-to-connect-an-azu...
Now, head to https://portal.azure.com/. You will be offered a tour of the suite; you
can do this later.
3 of 22 2/6/2024, 12:52 PM
How to connect an Azure database to third-party services |... https://medium.com/@dmobjects/how-to-connect-an-azu...
Create a new resource group, add a database name and create a new server. Take
note of the information provided, you’ll need it later!
4 of 22 2/6/2024, 12:52 PM
How to connect an Azure database to third-party services |... https://medium.com/@dmobjects/how-to-connect-an-azu...
You will be asked to review the creation of the database, alongside the estimated
cost per month of using it.
Now, select “SQL Databases” on the left-side panel, choose your newly-created
database server and click “Set server firewall.”
Get your IP address by searching “what’s my ip” on Google and take note of it.
5 of 22 2/6/2024, 12:52 PM
How to connect an Azure database to third-party services |... https://medium.com/@dmobjects/how-to-connect-an-azu...
Then, create select “ON” on “Allow access to Azure services” and create a new
rule that includes your IP address.
Save your changes and once again, select “SQL Databases” and choose your new
server. Now, click “Connection strings” and take note of the connection strings.
Different services will require different connection strings.
6 of 22 2/6/2024, 12:52 PM
How to connect an Azure database to third-party services |... https://medium.com/@dmobjects/how-to-connect-an-azu...
Go back to “SQL Databases” and now select “Query Editor.” Put your admin
credentials and we will see the SQL Query editor. Let’s create a test table called
“Person” and insert “Will Williamson” as our test instance. Note that the Query
Editor allows us to export data as .csv and .xml, how cool is that?
7 of 22 2/6/2024, 12:52 PM
How to connect an Azure database to third-party services |... https://medium.com/@dmobjects/how-to-connect-an-azu...
First, let’s connect our database to Visual Studio, so we can make tests in the
future without having to mess around with our source code.
8 of 22 2/6/2024, 12:52 PM
How to connect an Azure database to third-party services |... https://medium.com/@dmobjects/how-to-connect-an-azu...
9 of 22 2/6/2024, 12:52 PM
How to connect an Azure database to third-party services |... https://medium.com/@dmobjects/how-to-connect-an-azu...
Now, we must enter the credentials that we noted earlier. Keep in mind that there
are three main components to this process: Server, database and username.
10 of 22 2/6/2024, 12:52 PM
How to connect an Azure database to third-party services |... https://medium.com/@dmobjects/how-to-connect-an-azu...
Now that Visual Studio is connected, the next step is to actually connect out
ASP.NET app to the database. To do that, we head down to the Web.config file and
we create a new block called “connectionStrings”. Inside, we must add the
ADO.NET connection string, alongside our database credentials.
11 of 22 2/6/2024, 12:52 PM
How to connect an Azure database to third-party services |... https://medium.com/@dmobjects/how-to-connect-an-azu...
We can test the connection by creating a SQL Query file and running it directly
from Visual Studio.
12 of 22 2/6/2024, 12:52 PM
How to connect an Azure database to third-party services |... https://medium.com/@dmobjects/how-to-connect-an-azu...
First, install PyODBC, which is the Open Database Controller for Python, which
allows it to connect to SQL Server instances. You can do so by opening a
command prompt and entering:
After successfully installing the package, open your IDE of choice and write the
following script:
import pyodbc
AZURE_STRING = <Insert your Azure SQL Server ODBC connection string here, with
its required credentials>
cnxn = pyodbc.connect(AZURE_STRING)
cursor = cnxn.cursor()
row = cursor.fetchone()
print(row)
Now, run the script and you should see our test instance appear onscreen.
You will be presented with all the compatible data sources for Power BI. Scroll
down and select Azure SQL Database.
Now enter the name of the server and the name of the database.
13 of 22 2/6/2024, 12:52 PM
How to connect an Azure database to third-party services |... https://medium.com/@dmobjects/how-to-connect-an-azu...
Note that there are two options under “Data Connectivity mode”:
• Import: This imports the result of queries from the database. It is useful if the
Power BI visualizations do not need to be updated all the time.
After clicking “OK”, you will be prompted to insert your credentials. Enter the
same credentials you used in the earlier steps.
14 of 22 2/6/2024, 12:52 PM
How to connect an Azure database to third-party services |... https://medium.com/@dmobjects/how-to-connect-an-azu...
15 of 22 2/6/2024, 12:52 PM
How to connect an Azure database to third-party services |... https://medium.com/@dmobjects/how-to-connect-an-azu...
SSMS has the issue that, when dealing with online services, it may be a tad too
slow. It is a fully-equipped suite for interacting with your SQL Server databases,
so it must get a lot of data from the current instance to work correctly.
When developing, it is always better to work locally, and after you’ve done your
tests, then it is advised to pass on to a remote test environment. This is because
query latency is oftentimes ignored, mainly because it is pretty much invisible in
local testing environments. Take your previsions!
After the connection has been established, you can create a “New Query” and see
our neat little test instance.
16 of 22 2/6/2024, 12:52 PM
How to connect an Azure database to third-party services |... https://medium.com/@dmobjects/how-to-connect-an-azu...
Conclusion
I hope that this little guide has been of use. Cloud-based computing is sure to
provide many solutions to software developers and in the case of Microsoft
Azure, opening a free trial account to test its services is just so easy. It is hard to
resist the wide variety of tools they offer.
For web and app design solutions feel free to visit my company’s website at
https://www.dmobjects.ca.
We offer competitive prices and we specialize in working with startups and small
businesses. Our services include web hosting, corporate emails, e-commerce
platforms and much more.
17 of 22 2/6/2024, 12:52 PM
How to connect an Azure database to third-party services |... https://medium.com/@dmobjects/how-to-connect-an-azu...
Follow
We specialize in delivering the finest web design and custom application development for businesses.
18 of 22 2/6/2024, 12:52 PM
How to connect an Azure database to third-party services |... https://medium.com/@dmobjects/how-to-connect-an-azu...
Aasim Afridi
73 1
67
Lists
ChatGPT
21 stories · 439 saves
19 of 22 2/6/2024, 12:52 PM
How to connect an Azure database to third-party services |... https://medium.com/@dmobjects/how-to-connect-an-azu...
Beyza Ozgur
23
20 of 22 2/6/2024, 12:52 PM
How to connect an Azure database to third-party services |... https://medium.com/@dmobjects/how-to-connect-an-azu...
Lennart Svensson
11
Chirag Darji
Using Azure Key Vault Secrets with .NET Core 7 Web API
Topics covered in this article are…
21 of 22 2/6/2024, 12:52 PM
How to connect an Azure database to third-party services |... https://medium.com/@dmobjects/how-to-connect-an-azu...
Usamashafique
338 3
22 of 22 2/6/2024, 12:52 PM