A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/Azure-Samples/Hybrid-Compute-Python-Manage-VM below:

GitHub - Azure-Samples/Hybrid-Compute-Python-Manage-VM: Getting Started with Compute

page_type languages products description urlFragment

sample

python

azure

These samples demonstrate how to perform common management tasks

Hybrid-Compute-Python-Manage-VM

Hybrid-Compute-Python-Manage-VM

These samples demonstrate how to perform common management tasks with Microsoft AzureStack Virtual Machines using the Azure SDK for Python. The code provided shows how to do the following:

To see the code to perform these operations, check out the run_example() function in example.py. Each operation is clearly labeled with a comment and a print function. The examples are not necessarily in the order shown in the above list.

  1. If you don't already have it, install Python.

    This sample (and the SDK) is compatible with Python 2.7, 3.4, 3.5 and 3.6.

  2. General recommendation for Python development is to use a Virtual Environment. For more information, see https://docs.python.org/3/tutorial/venv.html

    Install and initialize the virtual environment with the "venv" module on Python 3 (you must install virtualenv for Python 2.7):

    python -m venv mytestenv # Might be "python3" or "py -3.6" depending on your Python installation
    cd mytestenv
    source bin/activate      # Linux shell (Bash, ZSH, etc.) only
    ./scripts/activate       # PowerShell only
    ./scripts/activate.bat   # Windows CMD only
    
  3. Clone the repository.

    git clone https://github.com/Azure-Samples/Hybrid-Compute-Python-Manage-VM.git
    
  4. Install the dependencies using pip.

    cd Hybrid-Compute-Python-Manage-VM
    pip install -r requirements.txt
    
  5. Create a service principal to work against AzureStack. Make sure your service principal has contributor/owner role on your subscription.

  6. Fill in and export these environment variables into your current shell.

    export AZURE_RESOURCE_LOCATION={your resource location}
    export AZURE_TENANT_ID={your tenant id}
    export AZURE_CLIENT_ID={your client id}
    export AZURE_CLIENT_SECRET={your client secret}
    export AZURE_SUBSCRIPTION_ID={your subscription id}
    export ARM_ENDPOINT={your AzureStack Resource Manager Endpoint}
    
  7. Note that in order to run this sample, Ubuntu 16.04-LTS and WindowsServer 2012-R2-Datacenter images must be present in AzureStack market place. These can be either downloaded from Azure or added to Platform Image Repository.

  8. Run the sample.

Retrieving a VM's OS disk

You may be tempted to try to retrieve a VM's OS disk by using virtual_machine.storage_profile.os_disk. In some cases, this may do what you want, but be aware that it gives you an OSDisk object. In order to update the OS Disk's size, as example.py does, you need not an OSDisk object but a Disk object. example.py gets the Disk object with the following:

os_disk_name = virtual_machine.storage_profile.os_disk.name
os_disk = compute_client.disks.get(GROUP_NAME, os_disk_name)

Here are some helpful links:

If you don't have a Microsoft Azure subscription you can get a FREE trial account here.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4