Last active
October 3, 2017 17:11
-
-
Save kevinhillinger/96daa1dd129acfc568278286a5038945 to your computer and use it in GitHub Desktop.
Azure Container Instance - Create - Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from azure.common.credentials import ServicePrincipalCredentials | |
from azure.mgmt.containerinstance import ContainerInstanceManagementClient | |
from azure.mgmt.containerinstance.models import ContainerGroup | |
from azure.mgmt.containerinstance.models import IpAddress | |
subscription_id = os.environ.get( | |
'AZURE_SUBSCRIPTION_ID', | |
'11111111-1111-1111-1111-111111111111') # your Azure Subscription Id | |
credentials = ServicePrincipalCredentials( | |
client_id=os.environ['AZURE_CLIENT_ID'], | |
secret=os.environ['AZURE_CLIENT_SECRET'], | |
tenant=os.environ['AZURE_TENANT_ID'] | |
) | |
resource_group_name = '<resource group name>' | |
container_group_name = '<container group name>' | |
ip_address = IpAddress() | |
ip_address.type = "Public" | |
container_group = ContainerGroup( | |
location = "eastus", | |
restart_policy = None, | |
ip_address = ip_address, | |
os_type = "" | |
) | |
client = ContainerInstanceManagementClient(credentials, subscription_id) | |
async_create = client.container_groups.create_or_update(resource_group_name, container_group_name, container_group) | |
async_create.result() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment