I'm trying to get the list of RecoveryServiceVaults by resource group name using Azure SDK package for Python azure.mgmt.recoveryservices. .
I coded as follows;
from azure.identity import ClientSecretCredential
from azure.mgmt.recoveryservices import RecoveryServicesClient
from azure.mgmt.recoveryservices.operations import VaultsOperations
subscription_id = os.environ["AZURE_SUBSCRIPTION_ID"]
tenant_id = os.environ["AZURE_TENANT_ID"]
client_id = os.environ["AZURE_CLIENT_ID"]
client_secret = os.environ["AZURE_CLIENT_SECRET"]
credentials = ClientSecretCredential(tenant_id=tenant_id, client_id=client_id, client_secret=client_secret)
recovery_services_client = RecoveryServicesClient(credentials=credentials,subscription_id=subscription_id)
vault=VaultsOperations(recovery_services_client)
vaults_in_rg = vault.list_by_resource_group(rg_name)
for vault in vaults_in_rg:
print(vault)
And the Error I got is;
TypeError: VaultsOperations.__init__() missing 3 required positional arguments: 'config',
'serializer', and 'deserializer'.
I don't know what variables I should provide to create VaultsOperations() class object. Could you give some guidance ?
Does anyone know what kind of variable should be provided for object to be created?
Any opinions is appreciated.
Thanks in advance
Based on the Microsoft Documentation :-
We should not instantiate this class directly. Instead, you should create a Client instance that instantiates it for you and attaches it as an attribute.
Also make sure to provide Base url
in your code as below as you have not added the required parameter as mentioned here
:
RecoveryServicesClient(credential: "TokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any)
For more information please refer to this GitHub samples .