Microsoft 365 にドメインを追加する
※作業はグローバル管理者で行います
Microsoft 365 管理センター にアクセスして「設定」-「ドメイン」を開いて「ドメインの追加」を選択します。
ドメイン名を入力して「このドメインを使用する」ボタンをクリックします。
「ドメインの DNS レコードに TXT レコードを追加する」を選択して「続行」ボタンをクリックします。
追加するレコードの情報を確認します。(ここではお名前.comを使っています)
DNS ホスティングプロバイダー側で DNS レコードの追加を行います。
追加が終わったら「確認」ボタンをクリックします。
「その他のオプション」を選択すると選択肢が表示されます。
「自分の DNS レコードを追加する」を選択して「続行」ボタンをクリックします。
DNS ホスティングプロバイダー側で DNS レコードの追加を行います。
追加が終わったら「続行」ボタンをクリックします。
ドメイン追加完了です。
ドメインの情報を確認するとこんな感じになってます。
では次に登録したドメインのサブドメインを登録してみましょう。
サブドメインの場合はドメインの所有の確認はスキップされます。
「続行」
サブドメインの場合は(?) All Company グループは作られないみたいですね。
Visual Studio で JSON からクラスを自動生成
ASP.NET Core Blazor WebAssembly でランダムにわんこを表示する
Dog API を使って Blazor でランダムにわんこを表示させます。
環境
Microsoft Visual Studio Community 2019 Version 16.9.3
プロジェクト作成
BlazorDog
という名前で新しい Blazor WebAssembly プロジェクトを作成します。
[ASP.NET Core でホストされた] を選択しておきます。
Dog クラス作成
BlazorDog.Shared
プロジェクト直下に Dog
クラスを追加します。
namespace BlazorDog.Shared { public class Dog { public string Message { get; set; } public string Status { get; set; } } }
IHttpClientFactory の登録
BlazorDog.Server
プロジェクトの Startup.cs
を以下のように書き換えて IHttpClientFactory を登録します
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; namespace BlazorDog.Server { public class Startup { public Startup(IConfiguration configuration) { Configuration = configuration; } public IConfiguration Configuration { get; } // This method gets called by the runtime. Use this method to add services to the container. // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 public void ConfigureServices(IServiceCollection services) { services.AddHttpClient(); // 追加 services.AddControllersWithViews(); services.AddRazorPages(); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseWebAssemblyDebugging(); } else { app.UseExceptionHandler("/Error"); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseHttpsRedirection(); app.UseBlazorFrameworkFiles(); app.UseStaticFiles(); app.UseRouting(); app.UseEndpoints(endpoints => { endpoints.MapRazorPages(); endpoints.MapControllers(); endpoints.MapFallbackToFile("index.html"); }); } } }
DogController 作成
BlazorDog.Server
プロジェクトの Controllers
フォルダー配下に DogController
コントローラーを追加します。
using BlazorDog.Shared; using Microsoft.AspNetCore.Mvc; using System.Net.Http; using System.Threading.Tasks; using System.Text.Json; namespace BlazorDog.Server.Controllers { [Route("api/[controller]")] [ApiController] public class DogController : ControllerBase { private readonly IHttpClientFactory clientFactory; public DogController(IHttpClientFactory clientFactory) { this.clientFactory = clientFactory; } [HttpGet] public async Task<ActionResult<Dog>> GetDogAsync() { var request = new HttpRequestMessage(HttpMethod.Get, "https://dog.ceo/api/breeds/image/random"); var client = clientFactory.CreateClient(); var response = await client.SendAsync(request); var responseString = await response.Content.ReadAsStringAsync(); var options = new JsonSerializerOptions { PropertyNameCaseInsensitive = true }; Dog dog = JsonSerializer.Deserialize<Dog>(responseString, options); return Ok(dog); } } }
Index ページの更新
BlazorDog.Client
プロジェクトの Pages
フォルダー配下の Index.razor
を以下のように書き換えます。
@page "/" @using BlazorDog.Shared @inject HttpClient Http @if (dog == null) { <p><em>Loading...</em></p> } else { <img src="@dog.Message" /> } @code { private Dog dog; protected override async Task OnInitializedAsync() { dog = await Http.GetFromJsonAsync<Dog>("api/dog"); } }
結果
実行するとこんな感じになりました。
Azure CLI / Azure AD PowerShell と Graph API
Azure AD Graph API は 2022 年 6 月 30 日に廃止される予定になっています。
https://docs.microsoft.com/en-us/graph/migrate-azure-ad-graph-planning-checklist
基本的に Azure AD Graph API を使っている場合は Microsoft Graph API に移行することになるんですが、 一方で Azure CLI や AzureAD PowerShell Module は未だに裏では Azure AD Graph API 使ってたりします。
もうあと 1 年ちょっとしかないけど、廃止されるまでに Microsoft Graph API 使うようにアップデートされるんでしょうか。そこそこ影響出そうな気がするけど。もしくは PowerShell の方はちょっと前に Microsoft Graph PowerShell SDK が GA したので今後はこっちをメインで使う方向になるのかな?
Azure CLI の方は現在 ADAL から MSAL への移行作業中かつ Microsoft Graph API 用の CLI も別で開発中とか。
https://github.com/Azure/azure-cli/issues/12946
現時点であんまり情報ないけどこのまま Azure CLI や Azure AD Module 使っていっていいものなのかしら。
blog init
just setting up my blog