<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Sven Glöckner</title>
    <description>The latest articles on DEV Community by Sven Glöckner (@sven5).</description>
    <link>https://dev.to/sven5</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F295657%2Fcb38bf6c-4e3b-41a1-a801-d697d6601796.jpeg</url>
      <title>DEV Community: Sven Glöckner</title>
      <link>https://dev.to/sven5</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sven5"/>
    <language>en</language>
    <item>
      <title>Running DevExpress XtraReports under Linux in App Service with custom fonts</title>
      <dc:creator>Sven Glöckner</dc:creator>
      <pubDate>Wed, 06 Mar 2024 20:18:40 +0000</pubDate>
      <link>https://dev.to/sven5/running-devexpress-xtrareports-under-linux-in-app-service-with-custom-fonts-3kk9</link>
      <guid>https://dev.to/sven5/running-devexpress-xtrareports-under-linux-in-app-service-with-custom-fonts-3kk9</guid>
      <description>&lt;p&gt;We have the need to convert our years-old SSRS reports to a newer technology to be able to lift a customer's web app to the Azure cloud. I decided to use DevExpress XtraReports, because there is a nice &lt;a href="https://docs.devexpress.com/XtraReports/1468/get-started-with-devexpress-reporting/convert-third-party-reports-to-devexpress-reports" rel="noopener noreferrer"&gt;import feature of existing SSRS reports&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;To reduce the overall monthly cost of running the Web App in Azure we decided to use a Azure App Service Linux plan. &lt;br&gt;
The reports need the use of custom fonts, i.e. for displaying barcodes.&lt;br&gt;
However, running XtraReports under Linux really isn't easy.&lt;/p&gt;

&lt;p&gt;I've found several information in the DevExpress documentation and Knowledge Base. Though, some information was outdated and didn't work, so my journey was like an adventure.&lt;br&gt;
Two years ago, I managed things getting to work using a custom Dockerfile to install missing Linux packages for the XtraReports.&lt;br&gt;
But today, I didn't want the overhead of creating a custom Dockerfile. I like a solution with plain Azure App Service for Linux, we only deploy a ZIP package that contains our code.&lt;/p&gt;

&lt;p&gt;Our web application runs on .NET 8.0 using DevExpress XtraReports v23.2.4 - The &lt;code&gt;WebDocumentViewer&lt;/code&gt; is used to display a report preview to the end user in the browser.&lt;/p&gt;

&lt;p&gt;Following are the steps needed to get things working.&lt;/p&gt;

&lt;h3&gt;
  
  
  Install these nuget packages
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;DevExpress.Drawing&lt;/li&gt;
&lt;li&gt;DevExpress.Drawing.Skia&lt;/li&gt;
&lt;li&gt;DevExpress.Reporting.Core&lt;/li&gt;
&lt;li&gt;Microsoft.ICU.ICU4C.Runtime&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Force the use of Skia rendering engine
&lt;/h3&gt;

&lt;p&gt;This step is optional, see note below.&lt;br&gt;
In Startup.cs force the use of the new Skia rendering engine &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
      DevExpress.Drawing.Internal.DXDrawingEngine.ForceSkia();
}


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;em&gt;DevExpress support note: The Skia engine automatically comes into use as long as you do not install libgdiplus.&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Add custom font to solution
&lt;/h3&gt;

&lt;p&gt;Add your custom font the Visual Studio solution and make sure it has the "Copy always" output folder property set. I decided to put my fonts in a folder named &lt;code&gt;fonts&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqzmd5njbpua53c8jxnf8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqzmd5njbpua53c8jxnf8.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Use a custom startup script for the App Service
&lt;/h3&gt;

&lt;p&gt;Use a startup script for the App Service to install missing libraries. I decided to name the file &lt;code&gt;run.sh&lt;/code&gt; and put it in my Visual Studio solution. The file should be set to "Copy Always" with no build process.&lt;/p&gt;

&lt;p&gt;the contents of the file&lt;/p&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

&lt;p&gt;&lt;span class="c"&gt;#!/bin/bash&lt;/span&gt;&lt;br&gt;
apt-get update &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;br&gt;
apt-get &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-y&lt;/span&gt; libc6 libicu-dev libfontconfig1&lt;br&gt;
&lt;span class="nb"&gt;cp &lt;/span&gt;fonts/FREE3OF9.TTF /usr/local/share/fonts&lt;br&gt;
fc-cache &lt;span class="nt"&gt;-f&lt;/span&gt; &lt;span class="nt"&gt;-v&lt;/span&gt;&lt;br&gt;
dotnet yourwebapp.dll&lt;/p&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  Configure the App Service to execute the startup script&lt;br&gt;
&lt;/h3&gt;

&lt;p&gt;Set the App Service startup script to our &lt;code&gt;run.sh&lt;/code&gt; in the portal&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuh4jx6ikje3zffmg4enp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuh4jx6ikje3zffmg4enp.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Helpful resources:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://supportcenter.devexpress.com/ticket/details/t1133108/reporting-for-asp-net-core-how-to-use-the-skiasharp-based-devexpress-drawing-engine" rel="noopener noreferrer"&gt;https://supportcenter.devexpress.com/ticket/details/t1133108/reporting-for-asp-net-core-how-to-use-the-skiasharp-based-devexpress-drawing-engine&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.devexpress.com/CoreLibraries/404247/devexpress-drawing-library" rel="noopener noreferrer"&gt;https://docs.devexpress.com/CoreLibraries/404247/devexpress-drawing-library&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>aspdotnet</category>
      <category>azure</category>
      <category>azureapp</category>
      <category>docker</category>
    </item>
    <item>
      <title>Update _id of MongoDB items</title>
      <dc:creator>Sven Glöckner</dc:creator>
      <pubDate>Thu, 08 Feb 2024 09:44:24 +0000</pubDate>
      <link>https://dev.to/sven5/update-id-of-mongodb-items-2kmg</link>
      <guid>https://dev.to/sven5/update-id-of-mongodb-items-2kmg</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;MongoServerError: Performing an update on the path '_id' would modify the immutable field '_id'&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;While updating the &lt;code&gt;_id&lt;/code&gt; is not possible, because this is an immutable field, there is another way to make this happen.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;iterate through the collection&lt;/li&gt;
&lt;li&gt;save the old &lt;code&gt;_id&lt;/code&gt; in a variable&lt;/li&gt;
&lt;li&gt;set the new &lt;code&gt;_id&lt;/code&gt; field value to &lt;code&gt;ObjectId&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;remove the old item&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Sample code:&lt;br&gt;
&lt;code&gt;db.products.find().forEach(function(doc){ &lt;br&gt;
    var oldId = doc._id&lt;br&gt;
    doc._id=ObjectId()&lt;br&gt;
    db.products.insert(doc)&lt;br&gt;
    db.products.deleteOne({ _id: oldId})&lt;br&gt;
})&lt;/code&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Document Versioning in MongoDB</title>
      <dc:creator>Sven Glöckner</dc:creator>
      <pubDate>Thu, 08 Feb 2024 07:38:55 +0000</pubDate>
      <link>https://dev.to/sven5/document-versioning-in-mongodb-dha</link>
      <guid>https://dev.to/sven5/document-versioning-in-mongodb-dha</guid>
      <description>&lt;p&gt;Recently, I'm working on a client's project with MongoDB. The need for versioning of documents came up. While searching the web I found really helpful information I'd like to share.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.mongodb.com/blog/post/building-with-patterns-the-document-versioning-pattern"&gt;https://www.mongodb.com/blog/post/building-with-patterns-the-document-versioning-pattern&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.askasya.com/post/revisitversions/"&gt;https://www.askasya.com/post/revisitversions/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I will go the way with "separate collection for previous versions".&lt;/p&gt;

</description>
      <category>mongodb</category>
    </item>
    <item>
      <title>Read Excel file from SharePoint Online into Azure SQL database</title>
      <dc:creator>Sven Glöckner</dc:creator>
      <pubDate>Wed, 14 Oct 2020 07:49:21 +0000</pubDate>
      <link>https://dev.to/sven5/read-excel-file-from-sharepoint-into-azure-sql-database-4d5f</link>
      <guid>https://dev.to/sven5/read-excel-file-from-sharepoint-into-azure-sql-database-4d5f</guid>
      <description>&lt;p&gt;We're already syncing files from on-premises network into our SPO (SharePoint Online) using OneDrive for Business.&lt;br&gt;
For a fast mock-up we decided to automatically read an Excel file into our Web App's Azure SQL database.&lt;br&gt;
I've been using &lt;a href="https://azure.microsoft.com/en-us/services/data-factory/" rel="noopener noreferrer"&gt;Azure Data Factory&lt;/a&gt; for this task and I've been really amazed how mature this tool is. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fdkzqzo0eicx87kflqze0.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fdkzqzo0eicx87kflqze0.jpg" alt="Azure Data Factory"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I've started with &lt;a href="https://docs.microsoft.com/en-us/azure/data-factory/connector-sharepoint-online-list#copy-file-from-sharepoint-online" rel="noopener noreferrer"&gt;this tutorial&lt;/a&gt;, it was really helpful. &lt;/p&gt;

&lt;p&gt;In the task &lt;strong&gt;CopyDataFromSPO&lt;/strong&gt; I've decided to store the Excel file in my already existing blob storage (sink). &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F87hd3vixxb0qoo4wkhyp.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F87hd3vixxb0qoo4wkhyp.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Afterwards, I created a data flow named &lt;strong&gt;SaveExcelFileToDb&lt;/strong&gt; where I read the Excel file from my blob and save it to my Azure SQL database. I always want to recreate the table with new data. This way I can easily workaround merge conflicts. However, this is a really simple solution for only demonstration purposes. In a real production environment there should be some additional and more fault-tolerant steps necessary. &lt;/p&gt;

</description>
      <category>azure</category>
      <category>sharepoint</category>
    </item>
    <item>
      <title>ASP.NET Core: Invalid log file path leads to startup failure on Azure App Service</title>
      <dc:creator>Sven Glöckner</dc:creator>
      <pubDate>Wed, 14 Oct 2020 06:58:36 +0000</pubDate>
      <link>https://dev.to/sven5/asp-net-core-invalid-log-file-path-leads-to-startup-failure-on-azure-app-service-37gl</link>
      <guid>https://dev.to/sven5/asp-net-core-invalid-log-file-path-leads-to-startup-failure-on-azure-app-service-37gl</guid>
      <description>&lt;p&gt;I've been using the default web.config with the setting &lt;code&gt;stdoutLogFile=".\LogFiles\stdout"&lt;/code&gt; for a while now.&lt;br&gt;
Yesterday, I created new App Service Slot as Staging environment.&lt;br&gt;
My build and release pipeline in Azure DevOps was running fine, but after deployment the App didn't start and I had several errors in the Application Event Logs, for instance:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Could not find 'aspnetcorev2_inprocess.dll'. Exception message:&lt;br&gt;
Invalid runtimeconfig.json [D:\home\site\wwwroot\MyApp.runtimeconfig.json] [D:\home\site\wwwroot\MyApp.runtimeconfig.dev.json]&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;I searched the web and found &lt;a href="https://github.com/dotnet/aspnetcore/issues/6465"&gt;this issue&lt;/a&gt;  on GitHub.&lt;br&gt;
It's already closed so we cannot add additional feedback there.&lt;/p&gt;

&lt;p&gt;I've tried the solution there and I was really amazed that afterwards my App Service is running fine. &lt;/p&gt;

&lt;p&gt;&lt;em&gt;TL;DR&lt;/em&gt;&lt;br&gt;
Change the stdoutLogFile setting to: &lt;code&gt;stdoutLogFile="\\?\%home%\LogFiles\stdout"&lt;/code&gt; 😏&lt;/p&gt;

</description>
      <category>azure</category>
      <category>csharp</category>
      <category>blazor</category>
      <category>dotnet</category>
    </item>
    <item>
      <title>Refreshing DxTreeView items and keep selection</title>
      <dc:creator>Sven Glöckner</dc:creator>
      <pubDate>Wed, 26 Feb 2020 16:19:08 +0000</pubDate>
      <link>https://dev.to/sven5/refreshing-dxtreeview-items-and-keep-selection-554b</link>
      <guid>https://dev.to/sven5/refreshing-dxtreeview-items-and-keep-selection-554b</guid>
      <description>&lt;p&gt;Today, I want to refresh the treeview items in a &lt;a href="https://demos.devexpress.com/blazor/"&gt;DevExpress Blazor&lt;/a&gt; DxTreeView.&lt;/p&gt;

&lt;p&gt;Imagine you edited one of the node's items and want to refresh the whole tree without loosing the selected node.&lt;/p&gt;

&lt;p&gt;My DxTreeView&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;DxTreeView @ref="@_treeView" AllowSelectNodes="true" SelectionChanged=@(async e =&amp;gt; await SelectChildNodeAsync(e))
    Data=@TreeViewItems
    NameExpression="@(dataItem =&amp;gt; ((Model.TreeViewItem)dataItem).Id.ToString())"
    TextExpression="@(dataItem =&amp;gt; ((Model.TreeViewItem)dataItem).Name)"
    ChildrenExpression="@(dataItem =&amp;gt; ((Model.TreeViewItem)dataItem).Items)"&amp;gt;
&amp;lt;/DxTreeView&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;After editing finished, you could programmatically refresh the treeview's datasource, expand and select the current node with the help of the API:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="n"&gt;TreeViewItems&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;DataAccess&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;GetTreeViewData&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;InvokeAsync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;StateHasChanged&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="n"&gt;_treeView&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ExpandToNode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nodeInfo&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;nodeInfo&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Name&lt;/span&gt; &lt;span class="p"&gt;==&lt;/span&gt; &lt;span class="n"&gt;DetailItem&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Id&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ToString&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
&lt;span class="n"&gt;_treeView&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;SelectNode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nodeInfo&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;nodeInfo&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Name&lt;/span&gt; &lt;span class="p"&gt;==&lt;/span&gt; &lt;span class="n"&gt;DetailItem&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Id&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ToString&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;a href="https://github.com/DevExpress/Blazor/issues/93"&gt;See also the issue on GitHub&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>blazor</category>
      <category>dotnet</category>
      <category>csharp</category>
      <category>aspnet</category>
    </item>
    <item>
      <title>Microsoft Graph API access denied in search for driveItems</title>
      <dc:creator>Sven Glöckner</dc:creator>
      <pubDate>Tue, 25 Feb 2020 12:08:30 +0000</pubDate>
      <link>https://dev.to/sven5/microsoft-graph-api-access-denied-in-search-for-driveitems-5fcf</link>
      <guid>https://dev.to/sven5/microsoft-graph-api-access-denied-in-search-for-driveitems-5fcf</guid>
      <description>&lt;p&gt;Currently, I'm developing a Blazor Web App that reads files from another tenant's OneDrive. We need to have a search functionality through the files using the &lt;a href="https://docs.microsoft.com/en-us/graph/api/driveitem-search?view=graph-rest-1.0&amp;amp;tabs=http"&gt;search for files capability&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I'm using &lt;a href="https://www.nuget.org/packages/Microsoft.Graph/"&gt;MS Graph SDK&lt;/a&gt;.&lt;br&gt;
The code boils down to a simple one-liner:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="n"&gt;_graphClient&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Users&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;userId&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="n"&gt;Drive&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Search&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;term&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;Request&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;GetAsync&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;However, it didn't work and throwed a 401 error:&lt;br&gt;
&lt;code&gt;&lt;br&gt;
Status Code: Forbidden&lt;br&gt;
Microsoft.Graph.ServiceException: Code: accessDenied&lt;br&gt;
Message: The caller does not have permission to perform the action.&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;I already registered my App and added the &lt;code&gt;Files.Read.All&lt;/code&gt; permission but it just didn't work.&lt;br&gt;
Now I remembered, that OneDrive for Business uses Sharepoint as backend and it organizes files within sites. &lt;br&gt;
&lt;strong&gt;So they key is to also add the &lt;code&gt;Sites.Read.All&lt;/code&gt; permission.&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>dotnet</category>
      <category>csharp</category>
      <category>microsoftgraph</category>
      <category>blazor</category>
    </item>
    <item>
      <title>Using custom claims for Azure AD B2C roles</title>
      <dc:creator>Sven Glöckner</dc:creator>
      <pubDate>Fri, 14 Feb 2020 11:49:24 +0000</pubDate>
      <link>https://dev.to/sven5/using-custom-claims-for-azure-ad-b2c-roles-720</link>
      <guid>https://dev.to/sven5/using-custom-claims-for-azure-ad-b2c-roles-720</guid>
      <description>&lt;p&gt;As we already know, currently Azure AD B2C does not support roles out-of-the-box. But I think there is a fairly easy way to workaround this limitation by using a custom claim for this requirement.&lt;/p&gt;

&lt;p&gt;First, add a custom claim in Azure AD B2C portal - name it "Role". Remember to check this claim in your SignIn/SignUp user workflow so that it will be put into the authentication token.&lt;/p&gt;

&lt;p&gt;Then you can add a custom authorization Policy in your .NET Core project:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="n"&gt;services&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;AddAuthorization&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;options&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;AddPolicy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Admin"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;policy&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt;
         &lt;span class="n"&gt;policy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;RequireClaim&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"extension_Role"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Admin"&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Afterwards you're able to use this in your controller or Page (I'm using Blazor).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nf"&gt;Authorize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Policy&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Admin"&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And voilà - that's it!&lt;/p&gt;

</description>
      <category>azure</category>
      <category>dotnet</category>
      <category>csharp</category>
      <category>blazor</category>
    </item>
  </channel>
</rss>
