惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Hugging Face - Blog
Hugging Face - Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
人人都是产品经理
人人都是产品经理
Microsoft Azure Blog
Microsoft Azure Blog
Engineering at Meta
Engineering at Meta
B
Blog RSS Feed
大猫的无限游戏
大猫的无限游戏
博客园_首页
雷峰网
雷峰网
V
Visual Studio Blog
爱范儿
爱范儿
A
About on SuperTechFans
量子位
N
Netflix TechBlog - Medium
Microsoft Security Blog
Microsoft Security Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
MongoDB | Blog
MongoDB | Blog
U
Unit 42
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
月光博客
月光博客
S
SegmentFault 最新的问题
J
Java Code Geeks
H
Hackread – Cybersecurity News, Data Breaches, AI and More

博客园 - 衡子

Ubuntu24.04更改SSH端口 记录安装过程 Azure CLI创建管理员用户 创建VMSS中的instance 创建不带公网IP的VM Azure LSv3系列VM 自动挂载NVMe本地磁盘 Azure Linux VM使用Managed Identity获取Key-vault的Secret Azure AD SSO with Google Cloud Identity 通过VM SWAP OS DISK升级VM 通过API获取Azure KeyVault Securet Azure Front Door添加自定义域名 VM间网络PPS和带宽测试 Azure获取access token的方法 VM间记录时延 Windows Terminal的一些配置 安装hping Azure解除不再使用Directory的关联 使用VSCode Remote Containers功能实现开发环境统一 Azure AKS容器网络详解
Azure AD访问Azure Storage
衡子 · 2022-07-12 · via 博客园 - 衡子

通过Azure AD的service Principal申请access token,可以不使用Azure的Storage Account Key来访问Azure的存储资源。

具体方法如下:

name="whuser01"
sa="hwst"

sub_id=$(az account list --query "[?isDefault]" | jq -r .[].id)

az ad sp create-for-rbac -n $name --role reader --scopes /subscriptions/$sub_id

client_id=$(az ad sp list --display-name $name | jq -r .[].appId)
tenant_id=$(az ad sp list --display-name $name | jq -r .[].appOwnerOrganizationId)


secret="xxxxxxxx"

export token="$(curl -X POST \
    -d "grant_type=client_credentials" \
    -d "client_id=$client_id" \
    -d "client_secret=$secret" \
    -d "resource=https://storage.azure.com/" \
    https://login.microsoftonline.com/$tenant_id/oauth2/token | jq -r .access_token)"

curl --oauth2-bearer "$token" -i \
    -H 'x-ms-version: 2017-11-09' \
    https://$sa.blob.core.windows.net/?comp=list