Sunday, December 17, 2017

D365FO: How to debug a non-development and a non-production environment

This post outlines the steps how to debug an issue which is happening in non-development or non-production environments e.g. UAT environment.




1.    RDP to your environment where you want to debug the issue, with this example I am connecting to UAT (Sandbox). 
2.    Connect to SQL server
a.     Get the server name from LCS database accounts
b.    Use .database.windows.net to connect to database


3.    Create a new SQL sign-in that the developer can use. This step lets the system administrator maintain the security of the sandbox environment. The developer will have access to one database for only a limited time. Use the following code to create the new SQL sign-in.

CREATE USER devtempuser WITH PASSWORD = 'pass@word1'
EXEC sp_addrolemember 'db_owner', 'devtempuser'

4.    Stop following services in development box
a.     IIS or world wide web publishing service development box
b.    Microsoft Dynamics 365 unified Operations: Batch Management service

5.    Go to J:\AosService\WebRoot\web.config.
6.    Save a copy of the original web.config file, so that you can switch back later. I copied file in the same directory and renamed the web.config to webDev.config and copied one to web.config
7.    Edit the following section in the web.config file.
Before your changes
<add key="DataAccess.Database" value="AxDB" />
<add key="DataAccess.DbServer" value="devDbServerName" />
<add key="DataAccess.SqlPwd" value="password" />
<add key="DataAccess.SqlUser" value="axdbadmin" />
After your changes
<add key="DataAccess.Database" value="sandboxdatabaseServerName" />
<add key="DataAccess.DbServer" value=" sandboxdbName.database.windows.net" />
<add key="DataAccess.SqlPwd" value="P@ssw0rd" />
<add key="DataAccess.SqlUser" value="devtempuser" />

8.    Start IIS or world wide web publishing service
9.    Do not start batch service otherwise your batch jobs of development box will start writing into UAT environment. Be careful with this step!!!
10.  Now, connect to your development box from browser. Oops!!! It does not connect and throw an error. Don’t worry let’s jump into event log and see what’s in there



Okay; so it is an access issue and here is the resolution for it.

11.  Execute the following command against Master database in UAT database server. IP address you get from the event viewer.

exec sp_set_firewall_rule N'PPDEV01', '13.70.85.22', '13.70.85.22'



Note: Restart IIS and make sure application pool is started

12.  Connect to development URL again from browser and this time it works. You can now access UAT database (all legal entities etc.)
13.  Restart or your start your VS in development box and attach to Process w3wp.exe to troubleshoot the issue(s)

Done with your debugging and got the resolution J

14.  Now it is time to remove devtempuser from UAT database, this prevents having the permanent access to the sandbox database. Right-click on the devtempuser user under Sabndoxdatabase | Security | Users and delete it.

15.  Stop IIS.

16.  Revert changes from the web.config file or simply delete the copied one and rename the original one from WebDev to Web.

17.  Start IIS.

18.  Start batch service 

19.  Connect to development environment URL and make sure it is connected to development database.

Reference: 
https://docs.microsoft.com/en-us/dynamics365/unified-operations/dev-itpro/dev-tools/debugx-issue-against-copy-of-production

5 comments:

  1. Hi, Thanks for the pretty well documented step-by-step procedure.

    One important aspect of debugging is to work with the correct version of the application. This means somewhere in one of the steps, you do need to get the correct version from the source control before you start the debugging.

    This can be done by getting the specific version dialog that let's you get the source code labeld with the same version as the one you have in your T2 environment.

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. Hi Daxture,
    useful info. thanks for the post!
    http://www.godparticles.in/

    ReplyDelete
  4. This comment has been removed by the author.

    ReplyDelete
  5. Hi ,

    I followed the steps given.

    I am getting error.

    Sorry, the server has encountered an error. It is either not available or it can't respond at this time. Please contact your system administrator.

    Error 500.

    And in event Viewer it shows:


    Event code: 3007
    Event message: A compilation error has occurred.
    Event time: 7/5/2019 9:07:12 AM
    Event time (UTC): 7/5/2019 9:07:12 AM
    Event ID: b9f480dc2ceb417095b61637d4c52079
    Event sequence: 3
    Event occurrence: 1
    Event detail code: 0

    Application information:
    Application domain: /LM/W3SVC/2/ROOT-1-132067912317932822
    Trust level: Full
    Application Virtual Path: /
    Application Path: K:\AosService\WebRoot\
    Machine name: ALT-DEV1-1

    Process information:
    Process ID: 15148
    Process name: w3wp.exe
    Account name: NT AUTHORITY\NETWORK SERVICE

    Exception information:
    Exception type: HttpCompileException
    Exception message: k:\AosService\WebRoot\App_Code\LocalizationController.cs(89): error CS0103: The name 'WebClientEventSource' does not exist in the current context
    at System.Web.Compilation.AssemblyBuilder.Compile()
    at System.Web.Compilation.BuildProvidersCompiler.PerformBuild()
    at System.Web.Compilation.CodeDirectoryCompiler.GetCodeDirectoryAssembly(VirtualPath virtualDir, CodeDirectoryType dirType, String assemblyName, StringSet excludedSubdirectories, Boolean isDirectoryAllowed)
    at System.Web.Compilation.BuildManager.CompileCodeDirectory(VirtualPath virtualDir, CodeDirectoryType dirType, String assemblyName, StringSet excludedSubdirectories)
    at System.Web.Compilation.BuildManager.CompileCodeDirectories()
    at System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled()
    at System.Web.Compilation.BuildManager.CallAppInitializeMethod()
    at System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException)



    Please suggest!

    ReplyDelete

I will appreciate your comments !

How to enable new Microsoft teams - Public Preview!

New Microsoft Teams is just AWESOME, quick but useful post below shows how you have this preview feature to make your life EASY!  Open Micr...