How to import CRM Orgnization Using CRM SQL Server backup file

Will import CRM Organization using Existing SQL Server CRM Database backup file. Follow the below steps,

Step 1: Open SQL Server Management Studio. I am using SQL Server 2012 Enterprise Edition.

Step 2: Provide Server name, Authentication, User name and Password. Click on Connect.

Import CRM Organization - Open SQL

Step 3: Take Backup of the Required Organization before do this Operation. Click here to know how to take backup of MSCRM Organization database backup.

Step 4: Right Click on Databases and click on Restore Database.

Import CRM Organization - Click on Restore Database

Step 5: Follow the below points,

  1. Select Device.
  2. Click on … (Browse) button.
  3. Click on Add.
  4. Browse bak file that you would like to create Org in MSCRM.
  5. Click OK and Ok.

Import CRM Organization - Locate BAK Data file

Step 6: Provide Destination Database Name that you would like to give for New CRM Organization and click ok.

Import CRM Organization - Provide Destination DB Name

Step 7: Once the database is restored, you can see the below Message and Click on OK.

Import CRM Organization - Restored Successfully

Step 8: Open CRM Deployment Manager and Click on Import Organization….

Import CRM Organization - Open Deployment Manager

Step 9: You can see the below SQL Server and Organization database name automatically. Click Next.

Import CRM Organization - Select Server and Organization Name

Step 10: Provide Display Name for the New CRM Organization. Automatically Unique Database Name will populate and Click on Next.

Import CRM Organization - Provide CRM Organization Name

Step 11: Report Server URL will auto populate or Provide required URL. Click on Next.

Import CRM Organization - Provide CRM Report Server URL

Step 12: Select Automatically Map Users, and click on Next.

Import CRM Organization - Map Users Automatically

Step 13: You will see the list of Active Directory Users. Click on Next.

Import CRM Organization - Edit User Mappings

Step 14: Click on Next.

Import CRM Organization - System Checks

Step 15: Click on Import.

Import CRM Organization - Ready to Import

Step 16: Update Organization is in Progress.

Import CRM Organization - Import Organization Wizard

Step 17: Organization imported Succesfully. Click on Finish.

Import CRM Organization - Organization created Succesfully

Step 18: Goto CRM Deployment Manager and browse for the Organization that you created.

Please provide your valuable comments on this article.

Advertisement

How to take CRM Organization database backup

Please follow the below steps to take CRM Organization database backup,

Step 1: Open SQL Server and Expand Databases. Right Click on required Organization to take Backup and Go to Tasks -> Back Up…Database Backup

Step 2: Would like to provide the new Destination Backup Path.

  1. Click on Remove to delete native path.

Provide Destination Path

2. Click on Add to add new Destination Path. Click on Ellipsis (…) button.

Select Path

Step 3: Select path and provide File Name and click on OK.

Provide Database File Name

Step 4: Click on OK to start backup.

Start Database Backup

Step 5: You can see the below Message, once Backup is created successfully.

Success Message

Please provide your valuable comments on this article.

Get all CRM Organizations using Discovery Service in C# and SDK

Follow the steps to retrieve all Organizations using Discovery Service,

Step 1: Create Console Application. Add below References to the project,

Discovery Service References

Step 2: Include the below namespaces,

using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Client;
using Microsoft.Xrm.Sdk.Discovery;

Step 3: Use the below Code to get all organizations using Discovery Service,

OnPremises

OnPremises:

public static List<string> GetOrganizations(string DiscoverServiceURL, string UserName, string Password, string Domain)
{
ClientCredentials credentials = new ClientCredentials();

credentials.Windows.ClientCredential = new System.Net.NetworkCredential(UserName, Password, Domain);
using (var discoveryProxy = new DiscoveryServiceProxy(new Uri(DiscoverServiceURL), null, credentials, null))
{
discoveryProxy.Authenticate();

// Get all Organizations using Discovery Service

RetrieveOrganizationsRequest retrieveOrganizationsRequest =
new RetrieveOrganizationsRequest()
{
AccessType = EndpointAccessType.Default,
Release = OrganizationRelease.Current
};

RetrieveOrganizationsResponse retrieveOrganizationsResponse =
(RetrieveOrganizationsResponse)discoveryProxy.Execute(retrieveOrganizationsRequest);

if (retrieveOrganizationsResponse.Details.Count >0)
{
var orgs = new List<String>();

foreach (OrganizationDetail orgInfo in retrieveOrganizationsResponse.Details)
orgs.Add(orgInfo.FriendlyName);

return orgs;
}
else
return null;
}
}

Usage:

GetOrganizations("https://XXXXXX/XRMServices/2011/Discovery.svc", "arunpotti@XXXXX.onmicrosoft.com", "P@ssw0rd!", "D0m@in");

Online:

OnPremises

public static List<string> GetOrganizations(string DiscoverServiceURL, string UserName, string Password)
{
ClientCredentials credentials = new ClientCredentials();
credentials.UserName.UserName = UserName;
credentials.UserName.Password = Password;

using (var discoveryProxy = new DiscoveryServiceProxy(new Uri(DiscoverServiceURL), null, credentials, null))
{
discoveryProxy.Authenticate();

// Get all Organizations using Discovery Service

RetrieveOrganizationsRequest retrieveOrganizationsRequest = new RetrieveOrganizationsRequest()
{
AccessType = EndpointAccessType.Default,
Release = OrganizationRelease.Current
};

RetrieveOrganizationsResponse retrieveOrganizationsResponse =
(RetrieveOrganizationsResponse)discoveryProxy.Execute(retrieveOrganizationsRequest);

if (retrieveOrganizationsResponse.Details.Count > 0)
{
var orgs = new List<String>();
foreach (OrganizationDetail orgInfo in retrieveOrganizationsResponse.Details)
orgs.Add(orgInfo.FriendlyName);

return orgs;
}
else
return null;
}
}

Usage:

GetOrganizations("https://disco.crm.dynamics.com/XRMServices/2011/Discovery.svc", "arunpotti@XXX.onmicrosoft.com", "P@ssw0rd!");

Step 4: Final Code is here,

using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel.Description;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Client;
using Microsoft.Xrm.Sdk.Discovery;

namespace GetOrganizations
{
class Program
{
static void Main(string[] args)
{
try
{
string OrgNames = string.Empty;

//Connecting to Online

List<string> lstOrgs = GetOrganizations("https://disco.crm.dynamics.com/XRMServices/2011/Discovery.svc", "arpotti@XXX.onmicrosoft.com", " P@ssw0rd!");

if (lstOrgs.Count > 0)
{
foreach (var Org in lstOrgs)
{
OrgNames = OrgNames + Org +"\n";
}

Console.Write("Organizations\n--------------\n"+OrgNames);                    Console.ReadKey();
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}

public static List<string> GetOrganizations(string DiscoverServiceURL, string UserName, string Password, string Domain)
{
ClientCredentials credentials = new ClientCredentials();            credentials.Windows.ClientCredential = new System.Net.NetworkCredential(UserName, Password, Domain);

using (var discoveryProxy = new DiscoveryServiceProxy(new Uri(DiscoverServiceURL), null, credentials, null))
{
discoveryProxy.Authenticate();

// Get all Organizations using Discovery Service

RetrieveOrganizationsRequest retrieveOrganizationsRequest = new RetrieveOrganizationsRequest()
{
AccessType = EndpointAccessType.Default,
Release = OrganizationRelease.Current
};

RetrieveOrganizationsResponse retrieveOrganizationsResponse =
(RetrieveOrganizationsResponse)discoveryProxy.Execute(retrieveOrganizationsRequest);

if (retrieveOrganizationsResponse.Details.Count >0)
{
var orgs = new List<String>();
foreach (OrganizationDetail orgInfo in retrieveOrganizationsResponse.Details)
orgs.Add(orgInfo.FriendlyName);
return orgs;
}
else
return null;
}
}

public static List<string> GetOrganizations(string DiscoverServiceURL, string UserName, string Password)
{
ClientCredentials credentials = new ClientCredentials();
credentials.UserName.UserName = UserName;
credentials.UserName.Password = Password;

using (var discoveryProxy = new DiscoveryServiceProxy(new Uri(DiscoverServiceURL), null, credentials, null))
{
discoveryProxy.Authenticate();

// Get all Organizations using Discovery Service

RetrieveOrganizationsRequest retrieveOrganizationsRequest =
new RetrieveOrganizationsRequest()
{
AccessType = EndpointAccessType.Default,
Release = OrganizationRelease.Current
};

RetrieveOrganizationsResponse retrieveOrganizationsResponse =
(RetrieveOrganizationsResponse)discoveryProxy.Execute(retrieveOrganizationsRequest);

if (retrieveOrganizationsResponse.Details.Count > 0)
{
var orgs = new List<String>();
foreach (OrganizationDetail orgInfo in retrieveOrganizationsResponse.Details)
orgs.Add(orgInfo.FriendlyName);

return orgs;
}
else
return null;
}
}
}
}

Step 5: Final Output is below,

Discovery Service Output