diff --git a/src/deployment/data_migration.py b/src/deployment/data_migration.py index 750473015..608ff5efb 100644 --- a/src/deployment/data_migration.py +++ b/src/deployment/data_migration.py @@ -1,8 +1,13 @@ -from azure.cosmosdb.table.tableservice import TableService -from azure.cosmosdb.table.models import Entity -from azure.cosmosdb.table.tablebatch import TableBatch +#!/usr/bin/env python +# +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. + import json -from typing import Optional, Callable, Dict, List +from typing import Callable, Dict, List + +from azure.cosmosdb.table.tablebatch import TableBatch +from azure.cosmosdb.table.tableservice import TableService def migrate_task_os(table_service: TableService) -> None: diff --git a/src/deployment/deploy.py b/src/deployment/deploy.py index 15357d7be..4ff3adad8 100644 --- a/src/deployment/deploy.py +++ b/src/deployment/deploy.py @@ -7,6 +7,7 @@ import argparse import json import logging import os +import platform import shutil import subprocess import sys @@ -74,6 +75,10 @@ TELEMETRY_NOTICE = ( "To disable, delete the ONEFUZZ_TELEMETRY application setting in the " "Azure Functions instance" ) +AZCOPY_MISSING_ERROR = ( + "azcopy is not installed and unable to use the built-in version. " + "Installation instructions are available at https://aka.ms/azcopy" +) FUNC_TOOLS_ERROR = ( "azure-functions-core-tools is not installed, " "install v3 using instructions: " @@ -127,11 +132,21 @@ class Client: self.migrations = migrations self.export_appinsights = export_appinsights - if os.name == "nt": - self.azcopy = os.path.join(self.tools, "win64", "azcopy.exe") - else: + machine = platform.machine() + system = platform.system() + + if system == "Linux" and machine == "x86_64": self.azcopy = os.path.join(self.tools, "linux", "azcopy") subprocess.check_output(["chmod", "+x", self.azcopy]) + elif system == "Windows" and machine == "AMD64": + self.azcopy = os.path.join(self.tools, "win64", "azcopy.exe") + else: + azcopy = shutil.which("azcopy") + if not azcopy: + raise Exception(AZCOPY_MISSING_ERROR) + else: + logger.warn("unable to use built-in azcopy, using system install") + self.azcopy = azcopy with open(workbook_data) as f: self.workbook_data = json.load(f) diff --git a/src/deployment/register_pool_application.py b/src/deployment/register_pool_application.py index c894f1b38..8ce1549c3 100644 --- a/src/deployment/register_pool_application.py +++ b/src/deployment/register_pool_application.py @@ -8,7 +8,7 @@ import json import logging import os from datetime import datetime, timedelta -from typing import Dict, List, Tuple, NamedTuple, Optional +from typing import Dict, List, NamedTuple, Optional, Tuple from uuid import UUID, uuid4 from azure.cli.core import get_default_cli # type: ignore @@ -23,7 +23,6 @@ from azure.graphrbac.models import ( from functional import seq from msrest.serialization import TZ_UTC - logger = logging.getLogger("deploy") @@ -120,7 +119,8 @@ def create_application_registration( required_resource_access=( [ RequiredResourceAccess( - resource_access=resource_access, resource_app_id=app.app_id, + resource_access=resource_access, + resource_app_id=app.app_id, ) ] if len(resource_access) > 0 @@ -268,7 +268,10 @@ def main(): formatter = argparse.ArgumentDefaultsHelpFormatter parser = argparse.ArgumentParser( formatter_class=formatter, - description="Create an application registration and/or generate a password for the pool agent", + description=( + "Create an application registration and/or " + "generate a password for the pool agent" + ), ) parser.add_argument("application_name") parser.add_argument("-v", "--verbose", action="store_true")