AzCopy 的 Azure AD 登录名还有多长时间过期?
How long before the AzCopy's Azure AD login expire?
我有一个每天 运行 的 python 脚本,它需要在每天的特定时间将文件上传到 Azure 存储。
我正在尝试使用 AzCopy 命令自动将文件上传到 Azure 存储。我计划登录一次 AzCopy 并让它 运行 并尽可能自动上传。
我从 azcopy login --tenant-id=<my tenant id>
开始,通过转到浏览器并输入代码手动验证 azcopy。
我想知道在我需要再次重新验证 azcopy 之前我可以保持登录状态多久?
PS。我不打算 运行 命令 azcopy logout
手动注销
不确定,但在这种情况下,更好的方式是非交互式方式,例如使用服务主体登录。
使用客户端密码作为服务主体登录:将环境变量 AZCOPY_SPA_CLIENT_SECRET
设置为基于密码的服务主体身份验证的客户端密码。
azcopy login --service-principal --application-id <your service principal's application ID>
参考 - https://docs.microsoft.com/en-us/azure/storage/common/storage-ref-azcopy-login#examples
更新:
与Azure CLI, after using azcopy login
, it will generate an accessToken.json
file in your local path ~/.azcopy/
(Azure CLI is ~/.azure/
), it includes the Auzre AD access token and refresh token, when the access token was expired, azcopy will use the refresh token to get a new access token and a new refresh token. It means if your refresh token does not expires, it can always get the new access token. By default, this refresh token is revoked after 90 days of inactivity, for the specific value, it depends on the specific token lifetime configuration in your AAD tenant相同。
总之,如果您经常在刷新令牌过期前使用 azcopy 命令,您可以始终保持登录状态。
我有一个每天 运行 的 python 脚本,它需要在每天的特定时间将文件上传到 Azure 存储。
我正在尝试使用 AzCopy 命令自动将文件上传到 Azure 存储。我计划登录一次 AzCopy 并让它 运行 并尽可能自动上传。
我从 azcopy login --tenant-id=<my tenant id>
开始,通过转到浏览器并输入代码手动验证 azcopy。
我想知道在我需要再次重新验证 azcopy 之前我可以保持登录状态多久?
PS。我不打算 运行 命令 azcopy logout
手动注销
不确定,但在这种情况下,更好的方式是非交互式方式,例如使用服务主体登录。
使用客户端密码作为服务主体登录:将环境变量 AZCOPY_SPA_CLIENT_SECRET
设置为基于密码的服务主体身份验证的客户端密码。
azcopy login --service-principal --application-id <your service principal's application ID>
参考 - https://docs.microsoft.com/en-us/azure/storage/common/storage-ref-azcopy-login#examples
更新:
与Azure CLI, after using azcopy login
, it will generate an accessToken.json
file in your local path ~/.azcopy/
(Azure CLI is ~/.azure/
), it includes the Auzre AD access token and refresh token, when the access token was expired, azcopy will use the refresh token to get a new access token and a new refresh token. It means if your refresh token does not expires, it can always get the new access token. By default, this refresh token is revoked after 90 days of inactivity, for the specific value, it depends on the specific token lifetime configuration in your AAD tenant相同。
总之,如果您经常在刷新令牌过期前使用 azcopy 命令,您可以始终保持登录状态。