はじめに
ショートカットやパイプラインなどでデータの連携は可能ですが、content-type が固定され、表示のさせ方の制御ができません。
本記事では Fabric Notebook で Azure Storage Blob SDK を使用して安全に認証しつつ content-type を指定する方法を記載します。
contet-type について
たとえば、pdf を表示させたい場合などは application/pdf とするなどのcontent-type を指定しないと、閲覧するのにダウンロード必須になったりします。
このあたりのわかりやすい紹介記事
方式
content-type の指定には、Azure Blob の Python SDK からContentSettings を使用します。
また、資格情報ユーティリティを使用することで、 Storage サービスのアクセストークンを取得することができます
token = notebookutils.credentials.getToken("storage")
実践
ファイルはレイクハウスのものを使います。このcontent-type を application/vnd.openxmlformats-officedocument.presentationml.presentation で up します
-
python ノートブックを起動します。
-
以下のコードを実行します。
pythondef publish_blob(account,container,target_path,source_path,content_type): from azure.storage.blob import BlobServiceClient , ContentSettings from azure.core.credentials import AccessToken from datetime import datetime, timedelta # トークン周り token_str = notebookutils.credentials.getToken("storage") class MyCredential: def get_token(self, *scopes, **kwargs): return AccessToken(token_str, int((datetime.utcnow() + timedelta(hours=1)).timestamp())) credential = MyCredential() # blob 操作 blob_service = BlobServiceClient( account_url = f"https://{account}.blob.core.windows.net", credential=credential ) blob = blob_service.get_blob_client(container, target_path) content_settings = ContentSettings( content_type=content_type ) with open(source_path, "rb") as f: blob.upload_blob( f, overwrite=True, blob_type="BlockBlob", content_settings=content_settings ) print(f"-----------------------------------------------------") print(f"upload_blob: {target_path}") filename = "fabric-november-2025-feature-summary.pptx" target_path = f"qiita/{filename}" source_path = f"/lakehouse/default/Files/pptx/{filename}" publish_blob( account = '<ストレージアカウント名>', container = '<コンテナ名>', target_path= target_path, source_path= source_path, content_type = "application/vnd.openxmlformats-officedocument.presentationml.presentation" ) -
Blob の URL を開くと PowerPoint がブラウザで直接閲覧できます。

以上です。参考になれば幸いです。





