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

推荐订阅源

Martin Fowler
Martin Fowler
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
雷峰网
雷峰网
J
Java Code Geeks
G
Google Developers Blog
博客园 - 司徒正美
The GitHub Blog
The GitHub Blog
L
LangChain Blog
人人都是产品经理
人人都是产品经理
GbyAI
GbyAI
Vercel News
Vercel News
S
SegmentFault 最新的问题
Engineering at Meta
Engineering at Meta
H
Hackread – Cybersecurity News, Data Breaches, AI and More
云风的 BLOG
云风的 BLOG
F
Fortinet All Blogs
Y
Y Combinator Blog
博客园_首页
Last Week in AI
Last Week in AI
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
罗磊的独立博客
A
About on SuperTechFans
B
Blog
Microsoft Security Blog
Microsoft Security Blog

博客园 - 衡子

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