def test_create_vault_client():
    vault_url = "vault_url"
    # pylint:disable=unused-variable
    # [START create_vault_client]

    from azure.identity import DefaultAzureCredential
    from azure.security.keyvault import VaultClient

    # Create a VaultClient using default Azure credentials
    credential = DefaultAzureCredential()
    vault_client = VaultClient(vault_url, credential)

    # [END create_vault_client]
    try:
        # [START create_async_vault_client]

        from azure.identity.aio import AsyncDefaultAzureCredential
        from azure.security.keyvault.aio import VaultClient

        # Create a VaultClient using default Azure credentials
        credential = AsyncDefaultAzureCredential()
        vault_client = VaultClient(vault_url, credential)

        # [END create_async_vault_client]
    except (ImportError, SyntaxError):
        pass
def test_create_secret_client():
    vault_url = "vault_url"
    # pylint:disable=unused-variable
    # [START create_secret_client]

    from azure.identity.aio import AsyncDefaultAzureCredential
    from azure.security.keyvault.aio.secrets import SecretClient

    # Create a SecretClient using default Azure credentials
    credentials = AsyncDefaultAzureCredential()
    secret_client = SecretClient(vault_url, credentials)
def test_create_key_client():
    vault_url = "vault_url"
    # pylint:disable=unused-variable
    # [START create_key_client]

    from azure.identity.aio import AsyncDefaultAzureCredential
    from azure.security.keyvault.aio import KeyClient

    # Create a KeyClient using default Azure credentials
    credential = AsyncDefaultAzureCredential()
    key_client = KeyClient(vault_url, credential)
示例#4
0
 def __init__(self, arguments):
     super().__init__(arguments)
     self.sync_credential = DefaultAzureCredential()
     self.sync_client = SchemaRegistryClient(
         fully_qualified_namespace=self.fully_qualified_namespace,
         credential=self.sync_credential,
     )
     self.async_credential = AsyncDefaultAzureCredential()
     self.async_client = AsyncSchemaRegistryClient(
         fully_qualified_namespace=self.fully_qualified_namespace,
         credential=self.async_credential,
     )
示例#5
0
    def __init__(self, arguments):
        super().__init__(arguments)

        # Auth configuration
        self.credential = DefaultAzureCredential()
        self.async_credential = AsyncDefaultAzureCredential()

        # Create clients
        vault_url = self.get_from_env("AZURE_KEYVAULT_URL")
        self.client = CertificateClient(vault_url, self.credential, **self._client_kwargs)
        self.async_client = AsyncCertificateClient(vault_url, self.async_credential, **self._client_kwargs)
        self.certificate_name = "livekvtestgetcertperfcert"
示例#6
0
    def __init__(self, arguments):
        super().__init__(arguments)

        # Auth configuration
        self.credential = DefaultAzureCredential()
        self.async_credential = AsyncDefaultAzureCredential()

        # Create clients
        vault_url = self.get_from_env("AZURE_KEYVAULT_URL")
        self.client = SecretClient(vault_url, self.credential, **self._client_kwargs)
        self.async_client = AsyncSecretClient(vault_url, self.async_credential, **self._client_kwargs)
        self.secret_names = ["livekvtestlistperfsecret{}".format(i) for i in range(self.args.list_size)]
    def __init__(self, arguments):
        super().__init__(arguments)

        # auth configuration
        self.metrics_uri = self.get_from_env('METRICS_RESOURCE_URI')
        self.names = ["MatchedEventCount"]
        self.aggregations = [MetricAggregationType.COUNT]

        # Create clients
        self.metrics_client = SyncMetricsQueryClient(
            credential=SyncDefaultAzureCredential())
        self.async_metrics_client = AsyncMetricsQueryClient(
            credential=AsyncDefaultAzureCredential())
示例#8
0
    def __init__(self, arguments):
        super().__init__(arguments)

        # auth configuration
        self.workspace_id = self.get_from_env('LOG_WORKSPACE_ID')

        self.query = "AppRequests | summarize avgRequestDuration=avg(DurationMs) by bin(TimeGenerated, 10m), _ResourceId"

        # Create clients
        self.logs_client = SyncLogsQueryClient(
            credential=SyncDefaultAzureCredential())
        self.async_logs_client = AsyncLogsQueryClient(
            credential=AsyncDefaultAzureCredential())
    def __init__(self, arguments):
        super().__init__(arguments)

        # Auth configuration
        self.credential = DefaultAzureCredential()
        self.async_credential = AsyncDefaultAzureCredential()

        # Create clients
        vault_url = self.get_from_env("AZURE_KEYVAULT_URL")
        self.client = KeyClient(vault_url, self.credential,
                                **self._client_kwargs)
        self.async_client = AsyncKeyClient(vault_url, self.async_credential,
                                           **self._client_kwargs)
        self.key_name = "livekvtestunwrapperfkey"
    def __init__(self, arguments):
        super().__init__(arguments)

        # auth configuration
        self.workspace_id = self.get_from_env('LOG_WORKSPACE_ID')

        # Create clients
        self.logs_client = SyncLogsQueryClient(
            credential=SyncDefaultAzureCredential())
        self.async_logs_client = AsyncLogsQueryClient(
            credential=AsyncDefaultAzureCredential())

        self.requests = [
            LogsQueryRequest(query="AzureActivity | summarize count()",
                             start_time=datetime(2021,
                                                 7,
                                                 25,
                                                 0,
                                                 0,
                                                 0,
                                                 tzinfo=timezone.utc),
                             end_time=datetime(2021,
                                               7,
                                               26,
                                               0,
                                               0,
                                               0,
                                               tzinfo=timezone.utc),
                             workspace_id=self.workspace_id),
            LogsQueryRequest(query="""AppRequests | take 10  |
                    summarize avgRequestDuration=avg(DurationMs) by bin(TimeGenerated, 10m), _ResourceId""",
                             start_time=datetime(2021,
                                                 7,
                                                 25,
                                                 0,
                                                 0,
                                                 0,
                                                 tzinfo=timezone.utc),
                             end_time=datetime(2021,
                                               7,
                                               26,
                                               0,
                                               0,
                                               0,
                                               tzinfo=timezone.utc),
                             workspace_id=self.workspace_id),
            LogsQueryRequest(query="AppRequests | take 20",
                             workspace_id=self.workspace_id,
                             include_statistics=True),
        ]
示例#11
0
 def __init__(self, arguments):
     super().__init__(arguments)
     self.sync_credential = DefaultAzureCredential()
     self.sync_client = SchemaRegistryClient(
         fully_qualified_namespace=self.fully_qualified_namespace,
         credential=self.sync_credential,
     )
     self.sync_encoder = AvroEncoder(client=self.sync_client,
                                     group_name=self.group_name,
                                     auto_register_schemas=True)
     self.async_credential = AsyncDefaultAzureCredential()
     self.async_client = AsyncSchemaRegistryClient(
         fully_qualified_namespace=self.fully_qualified_namespace,
         credential=self.async_credential,
     )
     self.async_encoder = AsyncAvroEncoder(client=self.async_client,
                                           group_name=self.group_name,
                                           auto_register_schemas=True)
示例#12
0
    def __init__(self, arguments):
        super().__init__(arguments)

        # Auth configuration
        self.credential = DefaultAzureCredential()
        self.async_credential = AsyncDefaultAzureCredential()

        # Create clients
        vault_url = self.get_from_env("AZURE_MANAGEDHSM_URL")
        self.client = KeyVaultAccessControlClient(vault_url, self.credential,
                                                  **self._client_kwargs)
        self.async_client = AsyncKeyVaultAccessControlClient(
            vault_url, self.async_credential, **self._client_kwargs)
        self.role_name = uuid.uuid4()
        self.scope = KeyVaultRoleScope.GLOBAL
        self.permissions = [
            KeyVaultPermission(
                data_actions=[KeyVaultDataAction.CREATE_HSM_KEY])
        ]