Skip to content

Commit

Permalink
Merge branch 'main' into m365-roadmap-graph-connector
Browse files Browse the repository at this point in the history
  • Loading branch information
mohammadamer authored Jun 10, 2024
2 parents 48a03fa + 164fa3a commit 96704a8
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 79 deletions.
143 changes: 69 additions & 74 deletions samples/dotnet-csharp-graphdocs-ttk/ConnectionConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,99 +20,94 @@ private static Dictionary<string, object> Layout
}
}

private static ExternalConnection _externalConnection = new ExternalConnection
public static ExternalConnection ExternalConnection => new ExternalConnection
{
Id = "msgraphdocs",
Name = "Microsoft Graph documentation",
Description = "Documentation for Microsoft Graph API which explains what Microsoft Graph is and how to use it.",
ActivitySettings = new()
{
UrlToItemResolvers = new()
{
new ItemIdResolver
{
UrlMatchInfo = new()
{
new ItemIdResolver
{
UrlMatchInfo = new()
{
BaseUrls = new() { "https://learn.microsoft.com" },
UrlPattern = "/[^/]+/graph/auth/(?<slug>[^/]+)",
},
ItemId = "auth__{slug}",
Priority = 1
},
new ItemIdResolver
{
UrlMatchInfo = new()
{
BaseUrls = new() { "https://learn.microsoft.com" },
UrlPattern = "/[^/]+/graph/sdks/(?<slug>[^/]+)",
},
ItemId = "sdks__{slug}",
Priority = 2
},
new ItemIdResolver
{
UrlMatchInfo = new()
{
BaseUrls = new() { "https://learn.microsoft.com" },
UrlPattern = "/[^/]+/graph/(?<slug>[^/]+)",
},
ItemId = "{slug}",
Priority = 3
}
}
BaseUrls = new() { "https://learn.microsoft.com" },
UrlPattern = "/[^/]+/graph/auth/(?<slug>[^/]+)",
},
ItemId = "auth__{slug}",
Priority = 1
},
new ItemIdResolver
{
UrlMatchInfo = new()
{
BaseUrls = new() { "https://learn.microsoft.com" },
UrlPattern = "/[^/]+/graph/sdks/(?<slug>[^/]+)",
},
ItemId = "sdks__{slug}",
Priority = 2
},
new ItemIdResolver
{
UrlMatchInfo = new()
{
BaseUrls = new() { "https://learn.microsoft.com" },
UrlPattern = "/[^/]+/graph/(?<slug>[^/]+)",
},
ItemId = "{slug}",
Priority = 3
}
}
},
SearchSettings = new()
{
SearchResultTemplates = new()
{
new()
{
Id = "msgraphdocs",
Priority = 1,
Layout = new Json
{
new()
{
Id = "msgraphdocs",
Priority = 1,
Layout = new Json
{
AdditionalData = Layout
}
}
AdditionalData = Layout
}
},
AdditionalData = new Dictionary<string, object>()
}
}
}
};

public static ExternalConnection ExternalConnection => _externalConnection;

private static Schema _schema = new Schema
public static Schema Schema => new Schema
{
BaseType = "microsoft.graph.externalItem",
Properties = new()
{
new Property
{
Name = "title",
Type = PropertyType.String,
IsQueryable = true,
IsSearchable = true,
IsRetrievable = true,
Labels = new() { Label.Title }
},
new Property
{
Name = "description",
Type = PropertyType.String,
IsQueryable = true,
IsSearchable = true,
IsRetrievable = true
},
new Property
{
Name = "url",
Type = PropertyType.String,
IsRetrievable = true,
Labels = new() { Label.Url }
}
}
{
new Property
{
Name = "title",
Type = PropertyType.String,
IsQueryable = true,
IsSearchable = true,
IsRetrievable = true,
Labels = new() { Label.Title }
},
new Property
{
Name = "description",
Type = PropertyType.String,
IsQueryable = true,
IsSearchable = true,
IsRetrievable = true
},
new Property
{
Name = "url",
Type = PropertyType.String,
IsRetrievable = true,
Labels = new() { Label.Url }
}
}
};

public static Schema Schema => _schema;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,11 @@ private async Task CheckSchemaStatus(string location)

private async Task CreateConnection(ConnectionMessage connectionMessage)
{
ConnectionConfiguration.ExternalConnection.ConnectorId = connectionMessage.ConnectorId;
var externalConnection = ConnectionConfiguration.ExternalConnection;
externalConnection.ConnectorId = connectionMessage.ConnectorId;

await _graphClient.External.Connections
.PostAsync(ConnectionConfiguration.ExternalConnection, request =>
.PostAsync(externalConnection, request =>
{
request.Headers.Add("GraphConnectors-Ticket", connectionMessage.ConnectorTicket!);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<PackageReference Include="Microsoft.ApplicationInsights.WorkerService" Version="2.22.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.ApplicationInsights" Version="1.2.0" />
<PackageReference Include="Microsoft.Extensions.Azure" Version="1.7.2" />
<PackageReference Include="Microsoft.Graph" Version="5.50.0" />
<PackageReference Include="Microsoft.Graph" Version="5.52.0" />
<PackageReference Include="YamlDotNet" Version="15.1.2" />
</ItemGroup>
<ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions samples/dotnet-csharp-graphdocs-ttk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ This sample project uses Teams Toolkit for Visual Studio to simplify the process

Version|Date|Comments
-------|----|--------
1.1|May 15, 2024|Updates connection configuration
1.0|May 3, 2024|Initial release

## Prerequisites
Expand Down
1 change: 1 addition & 0 deletions samples/dotnet-csharp-graphdocs-ttk/TokenValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public bool ValidateToken(string token)
switch (version)
{
case "1.0":
case null:
validIssuer = $"https://sts.windows.net/{_tenant}/";
break;
case "2.0":
Expand Down
2 changes: 1 addition & 1 deletion samples/dotnet-csharp-graphdocs-ttk/assets/sample.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"This sample project uses Teams Toolkit for Visual Studio to simplify the process of creating a Microsoft Graph connector that ingests markdown content from a custom API to Microsoft Graph. It provides an end to end example of creating the connector, ingesting content and refreshing the ingested content on a schedule. It also includes the simplified admin experience which means that admins can toggle the connector on and off from the Microsoft Teams admin center."
],
"creationDateTime": "2024-05-03",
"updateDateTime": "2024-05-03",
"updateDateTime": "2024-05-15",
"products": [
"Microsoft Graph connectors",
"Microsoft Graph",
Expand Down
1 change: 0 additions & 1 deletion samples/dotnet-csharp-m365-roadmap/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ Version|Date|Comments
- [Create result type](https://learn.microsoft.com/microsoftsearch/manage-result-types) with default settings and the external connection you've just created
- Use the `resultLayout.json` file for the Adaptive Card code


## Results Layout
- Browse to the admin center then Search & intelligence then update the result layout with the resultLayout json file.

Expand Down

0 comments on commit 96704a8

Please sign in to comment.