def run_example(config):
    try:
        my_subscription_id = config[
            'subscriptionId']  # your Azure Subscription Id
        my_resource_group = 'azure-python-deployment-sample'  # the resource group for deployment
        my_pub_ssh_key_path = os.path.expanduser(
            '~/.ssh/id_rsa.pub')  # the path to your rsa public key file

        msg = "\nInitializing the Deployer class with subscription id: {}, resource group: {}" \
            "\nand public key located at: {}...\n\n"
        msg = msg.format(my_subscription_id, my_resource_group,
                         my_pub_ssh_key_path)
        print(msg)

        # Initialize the deployer class
        deployer = Deployer(config, my_resource_group, my_pub_ssh_key_path)

        print("Beginning the deployment... \n\n")
        # Deploy the template
        my_deployment = deployer.deploy()

        print("Done deploying!!")

    finally:
        print("Cleaning up the deployment... \n\n")
        #Destroy the resource group which contains the deployment
        deployer.destroy()
        print("Clean up the deployment sucessfully. \n")
Esempio n. 2
0
# TODO: compare the wished for deployment with the current deployment
# TODO: delete ones not in desired state
# TODO: Update ones that are in current list
# TODO: create new ones if they don't exist


my_location = 'uksouth'
# the path to your rsa public key file
my_pub_ssh_key_path = os.path.expanduser('~/.ssh/id_rsa.pub')

msg = "\nInitializing the Deployer class with subscription id: {}, resource group: {}" \
    "\nand public key located at: {}...\n\n"
msg = msg.format(my_subscription_id, my_resource_group, my_pub_ssh_key_path)
print(msg)


# Initialize the deployer class
deployer = Deployer(my_subscription_id, my_resource_group,
                    my_location, my_pub_ssh_key_path)

print("Beginning the deployment... \n\n")
# Deploy the template
# deployer.deploy()

print("Done deploying!!\n\nYou can connect via: `ssh azureSample@{}.westus.cloudapp.azure.com`".format(
    deployer.dns_label_prefix))

# Destroy the resource group which contains the deployment
deployer.destroy()
()