Azure Python SDK Automation Runbook-错误 - ' clientsEtcretCredential'对象没有属性' signed_session'
我发现与Azure Python错误消息相关的帖子很少 - “ clients otretcredential”对象没有属性'signed_session'
,但是我正在从Azure Portal中测试我的代码,我正在使用Automation account runbook。我准备了用于更改存储帐户上TLS属性的脚本。我有两个AZ订阅位于不同租户(SUBA-服务提供商,Subb-服务客户)中,我正在使用Azure Lighthouse向SUBA帐户提供Admin访问到Subb。我正在使用Suba Azure AD中注册的SPN。我在笔记本电脑上测试了Python代码,并且所有作品都按预期进行了,我能够使用SUBA SPN -Service Principal修改位于Subb中的存储帐户。我正在从Azure Portal -Automation帐户运行书中测试相同的代码,并且我面临错误self._creds.signed_session(session)attributeError:'clients otretcredential'对象没有属性'signed_session'
。在自动化帐户中,我已经导入了包装,在下面列出。
我的Python代码,按照我的笔记本电脑的预期工作,从Azure Portal执行自动化运行手册时,提到了错误。
import sys
import json
from azure.mgmt.resource import SubscriptionClient
from azure.mgmt.resource import ResourceManagementClient
from azure.identity import ClientSecretCredential
import azure.mgmt.storage
subscription_id = "subB-subscriptionID"
tenant_id = "subA-TenantID"
client_id = "subA-clientID"
client_secret = "subA-clientSecret"
credential = ClientSecretCredential(
tenant_id=tenant_id,
client_id=client_id,
client_secret=client_secret)
storage_client = azure.mgmt.storage.StorageManagementClient(
credentials=credential,
subscription_id=subscription_id
)
storage_account = storage_client.storage_accounts.update(
"ResourceGroupName",
"StorageAccountName",
{
"properties": {
"minimumTlsVersion": "TLS1_2"
}
}
)
I found few posts related to Azure Python error message - 'ClientSecretCredential' object has no attribute 'signed_session'
, but I am testing my code from Azure portal, I am using Automation Account runbook. I prepared script for changing TLS property on Storage Account. I have two az subscriptions located in different tenants (subA - service provider, subB - service customer), I am using Azure Lighthouse to provide admin access from subA account to subB. I am using SPN registered in subA Azure AD. I tested Python code on my laptop and all works as expected, I was able to modify Storage Account located in subB using subA SPN - Service Principal. I am testing the same code from Azure Portal - Automation Account runbook and I am facing an error self._creds.signed_session(session)AttributeError: 'ClientSecretCredential' object has no attribute 'signed_session'
. In Automation Account I have imported packages, list below.
My Python code, works as expected from my Laptop, throwing mentioned error when executing as an automation runbook from Azure Portal.
import sys
import json
from azure.mgmt.resource import SubscriptionClient
from azure.mgmt.resource import ResourceManagementClient
from azure.identity import ClientSecretCredential
import azure.mgmt.storage
subscription_id = "subB-subscriptionID"
tenant_id = "subA-TenantID"
client_id = "subA-clientID"
client_secret = "subA-clientSecret"
credential = ClientSecretCredential(
tenant_id=tenant_id,
client_id=client_id,
client_secret=client_secret)
storage_client = azure.mgmt.storage.StorageManagementClient(
credentials=credential,
subscription_id=subscription_id
)
storage_account = storage_client.storage_accounts.update(
"ResourceGroupName",
"StorageAccountName",
{
"properties": {
"minimumTlsVersion": "TLS1_2"
}
}
)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我决定使用功能应用程序,而不是自动化运行书。函数包含所有Python代码,所有函数都可以正常工作,我测试了解决方案,所有解决方案都按预期工作。
Instead of Automation runbooks I decided to use Function app. Function contains all Python code and all works fine, I tested the solution and all works as expected.