{"generator":"Jekyll","link":[{"@attributes":{"href":"https:\/\/mephisztoe.github.io\/feed.xml","rel":"self","type":"application\/atom+xml"}},{"@attributes":{"href":"https:\/\/mephisztoe.github.io\/","rel":"alternate","type":"text\/html"}}],"updated":"2019-07-05T12:32:00+00:00","id":"https:\/\/mephisztoe.github.io\/feed.xml","title":"Zeit ist relativ. Kostbar.","subtitle":"Wie oft lernst Du jeden Tag etwas Neues und Du hattest bereits die verbl\u00fcffende Erkenntnis, dass eine sich immer schneller drehende Welt praktisch t\u00e4glich neue Innovationen bereith\u00e4lt. Geht mir auch so. Manchmal habe ich das Bed\u00fcrfnis, solche Erkenntnisse aufzuschreiben. Mir hilft das und vielleicht hat mein externes Ged\u00e4chtnis auch f\u00fcr Dich einen Nutzen.","entry":[{"title":"Azure Mobile Apps Client API und Azure Active Directory B2C. Geht das?","link":{"@attributes":{"href":"https:\/\/mephisztoe.github.io\/2019\/06\/17\/azure-app-services-auth.html","rel":"alternate","type":"text\/html","title":"Azure Mobile Apps Client API und Azure Active Directory B2C. Geht das?"}},"published":"2019-06-17T00:00:00+00:00","updated":"2019-06-17T00:00:00+00:00","id":"https:\/\/mephisztoe.github.io\/2019\/06\/17\/azure-app-services-auth","content":"<p>Entwickler mobiler L\u00f6sungen auf Basis von Xamarin Forms erleben derzeit eine besondere Situation insofern sie Azure App Services einsetzen. Der Grund daf\u00fcr ist u.a. der, dass es in relativ kurzer Zeit zu mehreren Rebrandings bei Microsoft gekommen ist. Leider liest Du dann nicht selten so etwas:<\/p>\n\n<blockquote>\n  <p>Microsoft is committed to fully supporting [\u2026], including support for the latest OS release, bug fixes,\ndocumentation improvements, and community PR reviews. Please note that the product team is not currently \ninvesting in any new feature work for [\u2026]. We highly appreciate community contributions to all areas of [\u2026].\u201d<\/p>\n<\/blockquote>\n\n<p>M\u00f6chtest Du z.B. <i>einfach<\/i> auf Deine Azure Tabellen zugreifen, k\u00f6nnte es ein guter Weg sein, die Azure Mobile Apps Client API einzusetzen. Die sind nicht zu Verwechseln mit den Azure Mobile Services, da das Produkt nun ja App Services hei\u00dft. Entsprechend findest Du auf github mehrere Projekte, die oberfl\u00e4chlich erst einmal sehr \u00e4hnlich zu sein scheinen und wenn Du nach Informationen dazu suchst, wirst Du immer \u00f6fter den Hinweis darauf finden, die Bibliotheken seien deprecated. Mist. Denn ich wei\u00df nicht, wie es Dir geht, aber ich pers\u00f6nlich mag eine integrierte M\u00f6glichkeit f\u00fcr Offline-Synchronisation und vor allem mag ich es, mit meinen Tabellen einfach so zu arbeiten:<\/p>\n\n<figure class=\"highlight\"><pre><code class=\"language-c#\" data-lang=\"c#\"><span class=\"kt\">var<\/span> <span class=\"n\">itemTable<\/span> <span class=\"p\">=<\/span> <span class=\"k\">await<\/span> <span class=\"k\">this<\/span><span class=\"p\">.<\/span><span class=\"n\">cloudService<\/span><span class=\"p\">.<\/span><span class=\"n\">GetTableAsync<\/span><span class=\"p\">&lt;<\/span><span class=\"n\">Item<\/span><span class=\"p\">&gt;();<\/span>\n<span class=\"kt\">var<\/span> <span class=\"n\">itemList<\/span> <span class=\"p\">=<\/span> <span class=\"k\">await<\/span> <span class=\"n\">itemTable<\/span><span class=\"p\">.<\/span><span class=\"nf\">ReadAllItemsAsync<\/span><span class=\"p\">();<\/span><\/code><\/pre><\/figure>\n\n<p>Bevor ich die API benutzt habe, hatte ich einen eigenen Requestprovider im Einsatz. Den brauche ich jetzt nur noch f\u00fcr externe Services, die keinen Client mitliefern. Das spart enorm viel ein!<\/p>\n\n<p>Da es auf den ersten Blick nicht offensichtlich ist, welche Bibliotheken denn nun die aktuellsten sind, die nicht mehr weitergepflegt werden, hier eine \u00dcbersicht:<\/p>\n\n<p>.NET Server SDK f\u00fcr Azure Mobile Apps (lies: Azure App Services)\n(<em>Aktuelle (stabile) Version: 2.0.3<\/em>)<\/p>\n<ul>\n  <li>Link zu <a href=\"https:\/\/github.com\/Azure\/azure-mobile-apps-net-server\">GitHub<\/a><\/li>\n  <li>Link zu <a href=\"https:\/\/www.nuget.org\/packages\/Microsoft.Azure.Mobile.Server\/\">Nuget<\/a><\/li>\n<\/ul>\n\n<p>Azure Mobile Apps: .NET Client SDK (lies: Azure App Services)\n(<em>Aktuelle (stabile) Version: 4.1.1<\/em>)<\/p>\n<ul>\n  <li>Link zu <a href=\"https:\/\/github.com\/Azure\/azure-mobile-apps-net-client\">GitHub<\/a><\/li>\n  <li>Link zu <a href=\"https:\/\/www.nuget.org\/packages\/Microsoft.Azure.Mobile.Client\">Nuget<\/a><\/li>\n<\/ul>\n\n<p>Okay. Nun hast Du also die aktuellsten (noch nicht ganz verwaisten) Bibliotheken am Start, um einfach mit Deinen Azure Tabellen herumhantieren zu k\u00f6nnen. Wenn das alles ist, was Dich interessiert, dann kannst Du nun wieder nach aktuellen Webcomics mit Entwickler-Bezug suchen.<\/p>\n\n<p>Solltest Du Dich aber bereits mit dem Azure Active Directory im Allgemeinen und dem B2C Angebot im Speziellen auseinandergesetzt haben, dann k\u00f6nntest Du sp\u00e4testens jetzt die Frage stellen, wie das denn nun mit der Authentifizierung funktioniert.<\/p>\n\n<p>Denn:\nDas .NET Client SDK f\u00fcr Azure App Services m\u00f6chtest Du nicht f\u00fcr Authentifizierung nutzen sondern f\u00fcr den einfachen Zugriff auf Azure Tabellen. Und Azure Active Directory B2C m\u00f6chtest Du nicht f\u00fcr die Arbeit mit Tabellen nutzen (haha, geht ja auch nicht), sondern zur Authentifizierung.<\/p>\n\n<p>Hier also, wie Du beides zur Zusammenarbeit bewegen kannst.<\/p>\n\n<h1 id=\"schritt-1\">Schritt 1<\/h1>\n\n<p>Initialisiere die PublicClientApplication so, wie Du es gewohnt bist.\nZ.B. so:<\/p>\n\n<figure class=\"highlight\"><pre><code class=\"language-c#\" data-lang=\"c#\"><span class=\"k\">public<\/span> <span class=\"k\">static<\/span> <span class=\"kt\">string<\/span> <span class=\"n\">Tenant<\/span> <span class=\"p\">=<\/span> <span class=\"s\">\"DEINEAPP.onmicrosoft.com\"<\/span><span class=\"p\">;<\/span>\n<span class=\"k\">public<\/span> <span class=\"k\">static<\/span> <span class=\"kt\">string<\/span> <span class=\"n\">AzureADB2CHostname<\/span> <span class=\"p\">=<\/span> <span class=\"s\">\"DEINEAPP.b2clogin.com\"<\/span><span class=\"p\">;<\/span>\n<span class=\"k\">public<\/span> <span class=\"k\">static<\/span> <span class=\"kt\">string<\/span> <span class=\"n\">PolicySignUpSignIn<\/span> <span class=\"p\">=<\/span> <span class=\"s\">\"B2C_1_SignInSignUp\"<\/span><span class=\"p\">;<\/span>\n<span class=\"k\">public<\/span> <span class=\"k\">static<\/span> <span class=\"kt\">string<\/span> <span class=\"n\">AuthorityBase<\/span> <span class=\"p\">=<\/span> <span class=\"s\">$\"https:\/\/<\/span><span class=\"p\">{<\/span><span class=\"n\">AzureADB2CHostname<\/span><span class=\"p\">}<\/span><span class=\"s\">\/tfp\/<\/span><span class=\"p\">{<\/span><span class=\"n\">Tenant<\/span><span class=\"p\">}<\/span><span class=\"s\">\/\"<\/span><span class=\"p\">;<\/span>\n<span class=\"k\">public<\/span> <span class=\"k\">static<\/span> <span class=\"kt\">string<\/span> <span class=\"n\">Authority<\/span> <span class=\"p\">=<\/span> <span class=\"s\">$\"<\/span><span class=\"p\">{<\/span><span class=\"n\">AuthorityBase<\/span><span class=\"p\">}{<\/span><span class=\"n\">PolicySignUpSignIn<\/span><span class=\"p\">}<\/span><span class=\"s\">\"<\/span><span class=\"p\">;<\/span>\n<span class=\"p\">...<\/span>\n<span class=\"n\">PCA<\/span> <span class=\"p\">=<\/span> <span class=\"k\">new<\/span> <span class=\"nf\">PublicClientApplication<\/span><span class=\"p\">(<\/span><span class=\"n\">ClientID<\/span><span class=\"p\">,<\/span> <span class=\"n\">Authority<\/span><span class=\"p\">);<\/span>\n<span class=\"n\">PCA<\/span><span class=\"p\">.<\/span><span class=\"n\">RedirectUri<\/span> <span class=\"p\">=<\/span> <span class=\"s\">$\"msal<\/span><span class=\"p\">{<\/span><span class=\"n\">ClientID<\/span><span class=\"p\">}<\/span><span class=\"s\">:\/\/auth\"<\/span><span class=\"p\">;<\/span>\n<span class=\"n\">PCA<\/span><span class=\"p\">.<\/span><span class=\"n\">ValidateAuthority<\/span> <span class=\"p\">=<\/span> <span class=\"k\">false<\/span><span class=\"p\">;<\/span><\/code><\/pre><\/figure>\n\n<h1 id=\"schritt-2\">Schritt 2<\/h1>\n\n<p>Beziehe wie \u00fcblich einen Token. Silent. In etwa so:<\/p>\n\n<figure class=\"highlight\"><pre><code class=\"language-c#\" data-lang=\"c#\"><span class=\"n\">IEnumerable<\/span><span class=\"p\">&lt;<\/span><span class=\"n\">IAccount<\/span><span class=\"p\">&gt;<\/span> <span class=\"n\">accounts<\/span> <span class=\"p\">=<\/span> <span class=\"k\">await<\/span> <span class=\"n\">App<\/span><span class=\"p\">.<\/span><span class=\"n\">PCA<\/span><span class=\"p\">.<\/span><span class=\"nf\">GetAccountsAsync<\/span><span class=\"p\">();<\/span>\n<span class=\"k\">if<\/span> <span class=\"p\">(<\/span><span class=\"n\">accounts<\/span> <span class=\"p\">!=<\/span> <span class=\"k\">null<\/span> <span class=\"p\">&amp;&amp;<\/span> <span class=\"n\">accounts<\/span><span class=\"p\">.<\/span><span class=\"nf\">Count<\/span><span class=\"p\">()<\/span> <span class=\"p\">&gt;<\/span> <span class=\"m\">0<\/span><span class=\"p\">)<\/span>\n<span class=\"p\">{<\/span>\n\t<span class=\"kt\">var<\/span> <span class=\"n\">response<\/span> <span class=\"p\">=<\/span> <span class=\"n\">Task<\/span><span class=\"p\">.<\/span><span class=\"nf\">Run<\/span><span class=\"p\">(<\/span><span class=\"k\">async<\/span> <span class=\"p\">()<\/span> <span class=\"p\">=&gt;<\/span> <span class=\"k\">await<\/span> <span class=\"n\">App<\/span><span class=\"p\">.<\/span><span class=\"n\">PCA<\/span><span class=\"p\">.<\/span><span class=\"nf\">AcquireTokenSilentAsync<\/span><span class=\"p\">(<\/span>\n    \t<span class=\"n\">App<\/span><span class=\"p\">.<\/span><span class=\"n\">Scopes<\/span><span class=\"p\">,<\/span>\n        <span class=\"n\">AuthenticationHelper<\/span><span class=\"p\">.<\/span><span class=\"nf\">GetAccountByPolicy<\/span><span class=\"p\">(<\/span><span class=\"n\">accounts<\/span><span class=\"p\">,<\/span> <span class=\"n\">App<\/span><span class=\"p\">.<\/span><span class=\"n\">PolicySignUpSignIn<\/span><span class=\"p\">),<\/span>\n        <span class=\"n\">App<\/span><span class=\"p\">.<\/span><span class=\"n\">Authority<\/span><span class=\"p\">,<\/span>\n        <span class=\"k\">false<\/span><span class=\"p\">));<\/span>\n\n\t<span class=\"n\">result<\/span> <span class=\"p\">=<\/span> <span class=\"n\">response<\/span><span class=\"p\">.<\/span><span class=\"n\">Result<\/span><span class=\"p\">;<\/span>\n<span class=\"p\">}<\/span>\n\n<span class=\"k\">if<\/span> <span class=\"p\">(<\/span><span class=\"n\">result<\/span> <span class=\"p\">!=<\/span> <span class=\"k\">null<\/span><span class=\"p\">)<\/span>\n\t<span class=\"k\">await<\/span> <span class=\"nf\">HandleResult<\/span><span class=\"p\">(<\/span><span class=\"n\">result<\/span><span class=\"p\">);<\/span><\/code><\/pre><\/figure>\n\n<h1 id=\"schritt-3\">Schritt 3<\/h1>\n\n<p>Tu, was immer Du musst, um mit dem Ergebnis richtig umzugehen - was immer \u201crichtig\u201d in Deinem Kontext hei\u00dft (bei mir z.B. lese ich aus dem Token die Object Id des AADB2C Users aus und verwende ihn als Referenz in meiner Azure-Datenbank, um eine Multi-User App zu erm\u00f6glichen).<\/p>\n\n<p>UND: Hier kannst Du nun das Azure .NET Client SDK initialisieren. Alles was Du brauchst, damit das funktioniert - denn auch das SDK ben\u00f6tigt eine korrekte Authentifizierung - ist der AccessToken aus dem Ergebnis des gerade erfolgten Logins via PublicClientApplication. Den AccessToken verpackst Du nun in einem JObject und \u00fcbergibst ihn an Deinen Azure Client:<\/p>\n\n<figure class=\"highlight\"><pre><code class=\"language-c#\" data-lang=\"c#\"><span class=\"k\">private<\/span> <span class=\"k\">async<\/span> <span class=\"n\">Task<\/span> <span class=\"nf\">HandleResult<\/span><span class=\"p\">(<\/span><span class=\"n\">AuthenticationResult<\/span> <span class=\"n\">result<\/span><span class=\"p\">)<\/span>\n<span class=\"p\">{<\/span>\n\t<span class=\"kt\">var<\/span> <span class=\"n\">zumoPayload<\/span> <span class=\"p\">=<\/span> <span class=\"k\">new<\/span> <span class=\"nf\">JObject<\/span><span class=\"p\">()<\/span>\n\t<span class=\"p\">{<\/span>\n\t\t<span class=\"p\">[<\/span><span class=\"s\">\"access_token\"<\/span><span class=\"p\">]<\/span> <span class=\"p\">=<\/span> <span class=\"n\">result<\/span><span class=\"p\">.<\/span><span class=\"n\">AccessToken<\/span>\n\t<span class=\"p\">};<\/span>\n\n\t<span class=\"k\">await<\/span> <span class=\"n\">CloudService<\/span><span class=\"p\">.<\/span><span class=\"nf\">LoginAsync<\/span><span class=\"p\">(<\/span><span class=\"n\">zumoPayload<\/span><span class=\"p\">);<\/span>\n    \n    <span class=\"p\">...<\/span>\n\n\t<span class=\"c1\">\/\/ Navigate to Main<\/span>\n    <span class=\"n\">App<\/span><span class=\"p\">.<\/span><span class=\"n\">Current<\/span><span class=\"p\">.<\/span><span class=\"n\">MainPage<\/span> <span class=\"p\">=<\/span> <span class=\"k\">new<\/span> <span class=\"nf\">AppShell<\/span><span class=\"p\">();<\/span>\n<span class=\"p\">}<\/span>\n\n\n<span class=\"k\">public<\/span> <span class=\"k\">async<\/span> <span class=\"n\">Task<\/span><span class=\"p\">&lt;<\/span><span class=\"n\">MobileServiceUser<\/span><span class=\"p\">&gt;<\/span> <span class=\"nf\">LoginAsync<\/span><span class=\"p\">(<\/span><span class=\"n\">JObject<\/span> <span class=\"n\">zumoPayload<\/span><span class=\"p\">)<\/span>\n<span class=\"p\">{<\/span>\n\t<span class=\"k\">return<\/span> <span class=\"k\">await<\/span> <span class=\"n\">client<\/span><span class=\"p\">.<\/span><span class=\"nf\">LoginAsync<\/span><span class=\"p\">(<\/span><span class=\"n\">MobileServiceAuthenticationProvider<\/span><span class=\"p\">.<\/span><span class=\"n\">WindowsAzureActiveDirectory<\/span><span class=\"p\">,<\/span>\n    \t<span class=\"n\">zumoPayload<\/span><span class=\"p\">);<\/span>\n<span class=\"p\">}<\/span><\/code><\/pre><\/figure>\n\n<p>Das ist es eigentlich auch schon. Der Code, den ich hier gezeigt habe, ist nicht zum Abschreiben gedacht, sondern als Unterst\u00fctzung. Im Prinzip findest Du solche und \u00e4hnliche L\u00f6sungen (sogar solche, die sich kopieren lassen), wenn Du im Internet nach dem Stichwort \u201cZumoPayload\u201d suchst. Viel Erfolg!<\/p>\n\n<p>Und vielleicht komme ich irgendwann dazu, ein funktionierendes Beispiel bei GitHub hochzuladen. Falls Du Interesse daran hast, schick\u2019 mir eine Email.<\/p>","author":{"name":"Mephisztoe"},"summary":"Entwickler mobiler L\u00f6sungen auf Basis von Xamarin Forms erleben derzeit eine besondere Situation insofern sie Azure App Services einsetzen. Der Grund daf\u00fcr ist u.a. der, dass es in relativ kurzer Zeit zu mehreren Rebrandings bei Microsoft gekommen ist. Leider liest Du dann nicht selten so etwas:"},{"title":"FontIcons in Xamarin.Forms 4.0 Shell Tabs einsetzen","link":{"@attributes":{"href":"https:\/\/mephisztoe.github.io\/2019\/06\/14\/xf4-shell-tabs-fonticons.html","rel":"alternate","type":"text\/html","title":"FontIcons in Xamarin.Forms 4.0 Shell Tabs einsetzen"}},"published":"2019-06-14T00:00:00+00:00","updated":"2019-06-14T00:00:00+00:00","id":"https:\/\/mephisztoe.github.io\/2019\/06\/14\/xf4-shell-tabs-fonticons","content":"<p>Vor kurzem habe ich einen spannenden Blogartikel von James Montemagno gelesen, in dem er erl\u00e4utert, wie sich FontIcons gan einfach in Xamarin.Forms 4 nutzen lassen. Den Artikel findest Du <a href=\"https:\/\/montemagno.com\/using-font-icons-in-xamarin-forms-goodbye-images-hello-fonts\/\">hier<\/a>. Nachdem ich die Material Design Icons in meine Projekte importiert und Dank der Website <a href=\"https:\/\/andreinitescu.github.io\/IconFont2Code\/\">IconFont2Code<\/a> eine Klasse f\u00fcr benannte Glyphen erstellt und eingebunden habe, musste ich aber feststellen, dass ich es nicht schaffe, FontIcons f\u00fcr Tabs in einer Xamarin Shell anzuzeigen.<\/p>\n\n<p>Praktisch alle Beispiele haben dazu in der AppShell.xaml unterhalb von ShellContent das Attribut ShellContent.Icon mittels FontImageSource gesetzt und hierin die IconFont referenziert. Klappt nur leider nicht.<\/p>\n\n<p>Das hier ist die L\u00f6usng:<\/p>\n\n<figure class=\"highlight\"><pre><code class=\"language-xml\" data-lang=\"xml\"><span class=\"nt\">&lt;Tab<\/span> <span class=\"na\">Title=<\/span><span class=\"s\">\"About\"<\/span><span class=\"nt\">&gt;<\/span>\n\t<span class=\"nt\">&lt;Tab.Icon&gt;<\/span>\n    \t<span class=\"nt\">&lt;FontImageSource<\/span> <span class=\"na\">FontFamily=<\/span><span class=\"s\">\"{DynamicResource MaterialFontFamily}\"<\/span>\n         \t\t\t\t <span class=\"na\">Glyph=<\/span><span class=\"s\">\"{x:Static local:IconFont.InformationOutline}\"<\/span>\n                         <span class=\"na\">Size=<\/span><span class=\"s\">\"30\"<\/span>\n                         <span class=\"na\">Color=<\/span><span class=\"s\">\"{StaticResource IconColor}\"<\/span> <span class=\"nt\">\/&gt;<\/span>\n\t<span class=\"nt\">&lt;\/Tab.Icon&gt;<\/span>\n    <span class=\"nt\">&lt;ShellContent<\/span> <span class=\"na\">Shell.NavBarIsVisible=<\/span><span class=\"s\">\"False\"<\/span>\n\t\t\t\t  <span class=\"na\">ContentTemplate=<\/span><span class=\"s\">\"{DataTemplate views:AboutView}\"<\/span> <span class=\"nt\">\/&gt;<\/span>\n<span class=\"nt\">&lt;\/Tab&gt;<\/span><\/code><\/pre><\/figure>","author":{"name":"Mephisztoe"},"summary":"Vor kurzem habe ich einen spannenden Blogartikel von James Montemagno gelesen, in dem er erl\u00e4utert, wie sich FontIcons gan einfach in Xamarin.Forms 4 nutzen lassen. Den Artikel findest Du hier. Nachdem ich die Material Design Icons in meine Projekte importiert und Dank der Website IconFont2Code eine Klasse f\u00fcr benannte Glyphen erstellt und eingebunden habe, musste ich aber feststellen, dass ich es nicht schaffe, FontIcons f\u00fcr Tabs in einer Xamarin Shell anzuzeigen."}]}