Exemple #1
0
    def __init__(self, group_name, location):
        self.location = location

        self.subscription_id = os.environ.get("SUBSCRIPTION_ID", None)

        # Use 2019-07-01 api version to test create VM
        self.compute_client = mgmt_compute.ComputeManagementClient(
            credential=DefaultAzureCredential(),
            subscription_id=self.subscription_id,
            api_version="2019-07-01")
        self.network_client = mgmt_network.NetworkManagementClient(
            credential=DefaultAzureCredential(),
            subscription_id=self.subscription_id)
        self.resource_client = mgmt_resource.ResourceManagementClient(
            credential=DefaultAzureCredential(),
            subscription_id=self.subscription_id)

        self.group = self.resource_client.resource_groups.create_or_update(
            group_name,
            # model style
            resource_models.ResourceGroup(location=self.location)

            # json style
            # {'location': self.location}
        )
Exemple #2
0
  def __init__(self,
               default_resource_group_name: str,
               default_region: str = 'eastus',
               profile_name: Optional[str] = None) -> None:
    """Initialize the AZAccount class.

    Args:
      default_resource_group_name (str): The default resource group in which to
          create new resources in. If the resource group does not exists,
          it will be automatically created.
      default_region (str): Optional. The default region to create new
          resources in. Default is eastus.
      profile_name (str): Optional. The name of the profile to use for Azure
          operations. For more information on profiles, see GetCredentials()
          in libcloudforensics.providers.azure.internal.common.py. Default
          does not use profiles and will authenticate to Azure using
          environment variables.
    """
    self.subscription_id, self.credentials = common.GetCredentials(profile_name)
    self.default_region = default_region
    self.compute_client = azure_compute.ComputeManagementClient(
        self.credentials, self.subscription_id)
    self.storage_client = storage.StorageManagementClient(
        self.credentials, self.subscription_id)
    self.resource_client = resource.ResourceManagementClient(
        self.credentials, self.subscription_id)
    self.network_client = network.NetworkManagementClient(
        self.credentials, self.subscription_id)
    self.default_resource_group_name = self._GetOrCreateResourceGroup(
        default_resource_group_name)
Exemple #3
0
    def __init__(self, az_account: 'account.AZAccount') -> None:
        """Initialize the Azure network class.

    Args:
      az_account (AZAccount): An Azure account object.
    """
        self.az_account = az_account
        self.network_client = network.NetworkManagementClient(
            self.az_account.credentials, self.az_account.subscription_id)