Exemplo n.º 1
0
    def query(
        self, log_query: str, *, timespan: str = "PT24H", raw: bool = False
    ) -> Any:
        """
        Perform an Application Insights query

        Queries should be well formed Kusto Queries.
        Ref https://docs.microsoft.com/en-us/azure/data-explorer/kql-quick-reference

        :param str log_query: Query to send to Application Insights
        :param str timespan: ISO 8601 duration format
        :param bool raw: Do not simplify the data result
        """
        creds, _ = get_azure_cli_credentials(
            resource="https://api.applicationinsights.io"
        )
        client = ApplicationInsightsDataClient(creds)

        app_id = self.onefuzz.info.get().insights_appid
        if app_id is None:
            raise Exception("instance does not have an insights_appid")
        raw_data = client.query.execute(
            app_id, body=QueryBody(query=log_query, timespan=timespan)
        )
        if "error" in raw_data.additional_properties:
            raise Exception(
                "Error performing query: %s" % raw_data.additional_properties["error"]
            )
        if raw:
            return raw_data
        return self._convert(raw_data)
Exemplo n.º 2
0
tenant          =   tenant[0]
subscription_id =   subscription_id[0]
source          =   source[0]
target          =   target[0]

# This program creates this resource group. If it's an existing resource group, comment out the code that creates the resource group
#rg_name = 'poc-westeurope-gp-data-rg'
rg_name = 'poc-westeurope-gp-data-rg'

# The data factory name. It must be globally unique.
#df_name = 'poc-westeurope-gp-data-df-atradius'        
df_name = 'poc-westeurope-gp-data-df'        


#credentials = ServicePrincipalCredentials(client_id=client_id, secret=secret, tenant=tenant)
credentials = get_azure_cli_credentials()
resource_client = ResourceManagementClient(credentials[0], credentials[1])
adf_client = DataFactoryManagementClient(credentials[0], credentials[1])

rg_params = {'location':'westeurope'}
df_params = {'location':'westeurope'}

# Create database linked service
ls_tgt_name = 'tgtazuresqldb'

# Create an Azure Storage linked service
ls_src_name = 'srcgrpblob'


# Parameter File with list of tables
with open('param_tables.json') as json_param_file:
Exemplo n.º 3
0
from azure.common.client_factory import get_client_from_cli_profile, get_azure_cli_credentials
from azure.mgmt.compute import ComputeManagementClient
from azure.mgmt.resource import ResourceManagementClient
from azure.mgmt.resource import SubscriptionClient

from azure.mgmt.resource import ResourceManagementClient
from azure.mgmt.storage import StorageManagementClient
from azure.mgmt.storage.models import StorageAccountCreateParameters

from pprint import pprint

from msrestazure.azure_active_directory import MSIAuthentication
from azure.mgmt.resource import ResourceManagementClient, SubscriptionClient
from azure.mgmt.advisor import AdvisorManagementClient

credentials, sub_id = get_azure_cli_credentials()

print(credentials)

# exit(0)
# subscriptionClient = get_client_from_cli_profile(SubscriptionClient)

subscriptionClient = SubscriptionClient(credentials)

for subscription in subscriptionClient.subscriptions.list():
    subscription_id = subscription.subscription_id

    print("Subcription ID: {} Name: {} State: {} \n\tAuth: {}".format(
        subscription.subscription_id, subscription.display_name,
        subscription.state, subscription.authorization_source))
    print("\tLocation: {} \n\tQuota: {} \n\tSpendLimit: {}".format(