Created
October 3, 2017 16:55
-
-
Save kevinhillinger/bc736d404c4dceb345b7f22dccd4b08f to your computer and use it in GitHub Desktop.
Azure Container Instance - Self Deletion - 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 | |
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 = os.environ['<ENV_RG_NAME'] | |
container_group_name = os.environ['<ENV_GROUP_VAR>'] | |
client = ContainerInstanceManagementClient(credentials, subscription_id) | |
async_delete = client.container_groups.delete(resource_group_name, container_group_name) | |
async_delete.result() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment