Sometimes
when working, you might need to connect to a managed environment (like UAT) to
debug if it is throwing some errors when running your functional process, where
the same data may not be available in
your development (Cloud hosted) environment. So, this post will help you to
connect the cloud DB of managed environment from your cloud hosted environment.
Why we need to connect?
Suppose you
are working on any managed services project or support project, based on SLA
you might need to provide interim or solution ASAP, may be in few hours.
Now, refreshing
the database for your development environment may take time, also there could
be some approvals to refresh your development environment, which results in
delay in providing the resolution if we like to use the same development
environment. In that case we connect to database of the managed
environment (UAT) and source code is from Cloud hosted (development)
environment.
How to connect?
If we
remember in AX2012 to connect to different instances, we connect to different
configuration files. Here also the same, we create a new config file and
we will configure and will connect it.
Where can we find config file?
Of course,
every machine will have the default config file, where the file contains
information of database and server. Check below path for web config file
K:\AosService\WebRoot
Procedure:
1. Add your
IP to safe list:
By default, all Sandbox Standard Acceptance
Test environments use Microsoft Azure SQL Database as their database platform.
The databases for these environments are protected by firewalls that restrict
access to the Application Object Server (AOS) with which it was originally
deployed.
A. You need
to add your IP to the enable list to log into Prod copy and open SSMS and write
SQL script to add to safe list
Maintain > Enable access
B. After
logged into the prod copy environment open SSMS,
Get the
server name, database name, user and password details from LCS project under
Database accounts.
Login,
Server: ‘ServerName’.database.windows.net
Username: axdbadmin
Password: ‘password of axdbadmin from LCS’
Connection Properties,
Connect to database: ‘Database name from LCS’
After
connecting to database from above procedure, write the below SQL script
EXECUTE sp_set_database_firewall_rule N'Debugging rule for
DevTest environment', 'a.b.c.d', 'a.b.c.d';
Note: a.b.c.d is the IP address of your dev
environment. Actually, it is the range else you can provide single IP.
C. After executing the above command, log into Dev environment and open SSMS, check whether you have access to database
Login,
Server: ‘ServerName’.database.windows.net
Username: axdbadmin
Password: ‘password of axdbadmin from LCS’
Connection Properties,
Connect
to database: ‘Database name from LCS’
D.
Now, you are able to connect to UAT database in SSMS
of DEV. In order to connect the D365FO application to UAT database, we need to
create or modify the config file in Webroot.
Duplicate
web config file and name it to web_UAT
Now open the web_UAT file in notepad and update the following
Database,
DbServer, SqlPwd, SQLUser
E.
Now the config file is ready, in order to connect
to UAT DB stop WWW (world wide web) service and rename the web file to web_Orig and web_UAT to
web, start the WWW service. Now your F&O application connected to UAT
database.
F.
In order to debug the UAT data, attach the
process in debug in VS.
G.
To connect back to dev database, stop WWW
service and change the web config file to web_UAT and web_Orig to web. Start the
WWW service.