Skip to content

Commit 46d9686

Browse files
committed
Added new sample code
1 parent 248b379 commit 46d9686

File tree

3 files changed

+49
-65
lines changed

3 files changed

+49
-65
lines changed

.openpublishing.publish.config.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,12 @@
5757
"url": "https://github.com/Microsoft/templates.docs.msft.pdf",
5858
"branch": "main",
5959
"branch_mapping": {}
60+
},
61+
{
62+
"path_to_root": "powerapps-samples",
63+
"url": "https://github.com/microsoft/PowerApps-Samples",
64+
"branch": "master",
65+
"branch_mapping": {}
6066
}
6167
],
6268
"branch_target_mapping": {

power-platform/alm/TOC.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,9 @@
131131
items:
132132
- name: Use PowerShell
133133
href: powershell-api.md
134-
- name: Work with solutions (SDK API)
134+
- name: Work with solutions (SDK API/C#)
135135
href: solution-api.md
136-
- name: Import, export, and staging
136+
- name: Stage, import, and export (SDK API/C#)
137137
href: solution-async.md
138138
- name: Create patches
139139
href: create-patches-simplify-solution-updates.md

power-platform/alm/solution-async.md

Lines changed: 41 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
---
2-
title: "Import, export, and staging of solutions | Microsoft Docs"
3-
description: "Learn about staging solutions and using an asynchronous job for import and export of large solution files."
2+
title: "Solution staging, with asynchronous import and export | Microsoft Docs"
3+
description: "Learn about staging solutions, and using an asynchronous job for import and export of large solution files."
44
keywords:
55
author: mikkelsen2000
66
ms.author: pemikkel
77
manager: kvivek
88
ms.custom: ""
9-
ms.date: 04/08/2021
9+
ms.date: 08/30/2021
1010
ms.reviewer: "pehecke"
1111
ms.service: powerapps
1212
ms.topic: "article"
@@ -17,71 +17,48 @@ search.app:
1717
- D365CE
1818
---
1919

20-
# Import, export, and staging of solutions
20+
# Solution staging, with asynchronous import and export
2121

22-
[!INCLUDE[applies-to-all](../includes/applies-to-all.md)]
22+
<!-- [!INCLUDE[applies-to-all](../includes/applies-to-all.md)] -->
2323

2424
Have you ever run into the situation during the import or export of a large solution where the operation times out? If so, you may be a candidate for performing the solution import/export asynchronously. This topic describes how to initiate the asynchronous import or export using the SDK and Web APIs.
2525

26-
## Solution import
26+
## Staging a solution
27+
28+
In comparison to importing a solution where the solution is imported and available in the environment right away, staging breaks the import process into more controllable phases. The staging process imports the solution as a "holding" solution where the administrator can decide when to make the staged solution available to users, or to perform an upgrade (in the case of a solution upgrade) in the target environment. Part of the staging process is validation of the staged solution. In this way you can stage the solution, know that the solution is valid, and schedule when to apply that solution or upgrade to the target environment.
2729

28-
`ImportSolution` is the action (or message) that performs the synchronous import operation. To execute the import operation asynchronously use `ImportSolutionAsync`.
2930

3031
| Operation | Web API | SDK API |
3132
| --- | --- | --- |
32-
| Import a solution | [ImportSolutionAsync](/dynamics365/customer-engagement/web-api/importsolutionasync) | [ImportSolutionAsyncRequest](/dotnet/api/microsoft.crm.sdk.messages.importsolutionasyncrequest) |
33+
| Stage a solution | [StageSolution](/dynamics365/customer-engagement/web-api/stagesolution) | use the generic [OrganizationRequest](/dotnet/api/microsoft.xrm.sdk.organizationrequest) and set the **RequestName** property to "StageSolution" |
3334

34-
Now let's take a look at some example code that demonstrates `ImportSolutionAsync`.
35+
The result of staging the solution will be a collection of validation results indicating success or failure and (if successful) a `StageSolutionUploadId` to be used in the `ImportSolutionAsync` call. See the import solution Web API sample code above for an example of how this is done.
3536

3637
### [SDK API (C#)](#tab/sdk-csharp)
3738

39+
:::code language="csharp" source="cds/orgsvc/c#/SolutionStageAndImport/Program.cs" id="snippet_stage-solution":::
40+
41+
### [Web API (C#)](#tab/webapi-csharp)
42+
3843
```csharp
39-
private void ImportSolutionUsingJob(IOrganizationService svc, string filepath)
40-
{
41-
byte[] fileBytes = File.ReadAllBytes(filepath);
42-
var param = new EntityCollection();
44+
// No sample code is available at this time
45+
```
4346

44-
var e1 = new Entity("connectionreference")
45-
{
46-
["connectionreferencelogicalname"] = "cr485_sharedmsnweather_01b85",
47-
["connectionreferencedisplayname"] = "MSN Weather",
48-
["connectorid"] = "/providers/Microsoft.PowerApps/apis/shared_msnweather",
49-
["connectionid"] = "bcb82cb72ed04d86b33407289cf458e0"
50-
};
47+
---
5148

52-
var e2 = new Entity("connectionreference")
53-
{
54-
["connectionreferencelogicalname"] = "cr485_sharedcommondataservice_eb48e",
55-
["connectionreferencedisplayname"] = "Common Data Service",
56-
["connectorid"] = "/providers/Microsoft.PowerApps/apis/shared_commondataservice",
57-
["connectionid"] = "c0701bf51f934042bc78e6a961babada"
58-
};
49+
## Solution import
5950

60-
var e3 = new Entity("connectionreference")
61-
{
62-
["connectionreferencelogicalname"] = "cr485_sharedsendmail_53930",
63-
["connectionreferencedisplayname"] = "Mail",
64-
["connectorid"] = "/providers/Microsoft.PowerApps/apis/shared_sendmail",
65-
["connectionid"] = "6c4b14bb6c66492786cdaf1f58f61d14"
66-
};
67-
68-
param.Entities.Add(e1);
69-
param.Entities.Add(e2);
70-
param.Entities.Add(e3);
71-
72-
// Demonstrating using a generic request and naming it. You could just use
73-
// the ImportSolutionAsyncRequest class.
74-
var r = new OrganizationRequest();
75-
r.RequestName = "ImportSolutionAsync";
76-
r["SolutionParameters"] = new SolutionParameters();
77-
r["OverwriteUnmanagedCustomizations"] = false;
78-
r["PublishWorkflows"] = true;
79-
r["CustomizationFile"] = fileBytes;
80-
r["ComponentParameters"] = param;
81-
82-
var response = proxy.Execute(r);
83-
}
84-
```
51+
`ImportSolution` is the action (or message) that performs the synchronous import operation. To execute the import operation asynchronously use `ImportSolutionAsync`.
52+
53+
| Operation | Web API | SDK API |
54+
| --- | --- | --- |
55+
| Import a solution | [ImportSolutionAsync](/dynamics365/customer-engagement/web-api/importsolutionasync) | [ImportSolutionAsyncRequest](/dotnet/api/microsoft.crm.sdk.messages.importsolutionasyncrequest) |
56+
57+
Now let's take a look at some example code that demonstrates `ImportSolutionAsync`.
58+
59+
### [SDK API (C#)](#tab/sdk-csharp)
60+
61+
:::code language="csharp" source="cds/orgsvc/c#/SolutionStageAndImport/Program.cs" id="snippet_import-solution-async":::
8562

8663
### [Web API (C#)](#tab/webapi-csharp)
8764

@@ -146,6 +123,18 @@ catch (Exception err)
146123

147124
The response returned from `ImportSolutionAsync` contains `ImportJobKey` and `AsyncOperationId`. The `ImportJobKey` value can be used to obtain the import result and the `AsyncOperationId` value can be used to track the import job status.
148125

126+
### [SDK API (C#)](#tab/sdk-csharp)
127+
128+
:::code language="csharp" source="cds/orgsvc/c#/SolutionStageAndImport/Program.cs" id="snippet_check-import-status":::
129+
130+
### [Web API (C#)](#tab/webapi-csharp)
131+
132+
```csharp
133+
// No sample code is available at this time
134+
```
135+
136+
---
137+
149138
## Solution export
150139

151140
`ExportSolution` is the action (or message) that performs the synchronous export operation. To execute the export operation asynchronously use `ExportSolutionAsync`.
@@ -197,14 +186,3 @@ var response = service.Execute(req);
197186
```
198187

199188
---
200-
201-
## Staging a solution import
202-
203-
In comparison to importing a solution where the solution is imported and available in the environment right away, staging breaks the import process into more controllable phases. The staging process imports the solution as a "holding" solution where the administrator can decide when to make the staged solution available to users, or to perform an upgrade (in the case of a solution upgrade) in the target environment. Part of the staging process is validation of the staged solution. This way you can stage the solution, know that the solution is valid, and schedule when to apply that solution or upgrade to the target environment.
204-
205-
206-
| Operation | Web API | SDK API |
207-
| --- | --- | --- |
208-
| Stage a solution | [StageSolution](/dynamics365/customer-engagement/web-api/stagesolution) | use the generic [OrganizationRequest](/dotnet/api/microsoft.xrm.sdk.organizationrequest) and set the **RequestName** property to "StageSolution" |
209-
210-
The result of staging the solution will be a collection of validation results indicating success or failure and (if successful) a `StageSolutionUploadId` to be used in the `ImportSolutionAsync` call. See the import solution Web API sample code above for an example of how this is done.

0 commit comments

Comments
 (0)