Python용 Azure Scheduler 라이브러리

라이브러리 설치

관리

pip install azure-mgmt-scheduler

예제

관리 클라이언트 만들기

다음 코드는 관리 클라이언트의 인스턴스를 만듭니다.

구독 목록에서 검색할 수 있는 항목을 제공해야 subscription_id 합니다.

Python SDK를 사용하여 Azure Active Directory 인증을 처리하고 Credentials 인스턴스를 만드는 방법에 대한 자세한 내용은 리소스 관리 인증을 참조하세요.

from azure.mgmt.scheduler import SchedulerManagementClient
from azure.common.credentials import UserPassCredentials

# Replace this with your subscription id
subscription_id = '33333333-3333-3333-3333-333333333333'

# See above for details on creating different types of AAD credentials
credentials = UserPassCredentials(
    'user@domain.com',	# Your user
    'my_password',		# Your password
)

scheduler_client = SchedulerManagementClient(
    credentials,
    subscription_id
)

작업 컬렉션 만들기

다음 코드는 기존 리소스 그룹 아래에서 작업 컬렉션을 만듭니다. 리소스 그룹을 만들거나 관리하려면 리소스 관리를 참조하세요.

from azure.mgmt.scheduler.models import JobCollectionDefinition, JobCollectionProperties, Sku

group_name = 'myresourcegroup'
job_collection_name = "myjobcollection"
scheduler_client.job_collections.create_or_update(
    group_name,
    job_collection_name,
    JobCollectionDefinition(
        location = "West US",
        properties = JobCollectionProperties(
            sku = Sku(
                name="Free"
            )
        )
    )
)
# scheduler_client is a JobCollectionDefinition instance