Dela via


Azure Scheduler-bibliotek för Python

Installera biblioteken

Hantering

pip install azure-mgmt-scheduler

Exempel

Skapa hanteringsklienten

Följande kod skapar en instans av hanteringsklienten.

Du måste ange vilken subscription_id som kan hämtas från din prenumerationslista.

Mer information om hur du hanterar Azure Active Directory-autentisering med Python SDK finns i Resource Management Authentication (Resurshanteringsautentisering ) och hur du skapar en Credentials instans.

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
)

Skapa en jobbsamling

Följande kod skapar en jobbsamling under en befintlig resursgrupp. Information om hur du skapar eller hanterar resursgrupper finns i Resurshantering.

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