Back

PowerShell Tips and Tricks for Azure

Earlier this month Microsoft announced new ways of working with Azure Resource Manager with PowerShell You can use a template to image a complete ga...

5 min read
Published on Nov 3, 2015
PowerShell Tips and Tricks for Azure

Earlier this month, Microsoft announced new ways of working with Azure Resource Manager with PowerShell. You can use a template to image a complete gallery, blog, wiki, or SharePoint portal to create resource groups that contain all of your resources. Once you do this, you can manage resource groups as logical units.

Here’s how you can use Azure PowerShell through Azure Resource Manager.

Before you begin

To complete the tasks and examples in this guide, you will need to have an Azure account and Azure PowerShell. You can open a free Azure account and use the free services including websites without incurring any charges unless you change your account settings. You will receive credits that can also be used toward some of the premium paid Azure services.

PowerShell cmdlets from Azure PowerShell 1.0 Preview don’t have to be installed yet because you can still use Azure PowerShell 0.9.8. The main difference is that the 1.0 Preview cmdlet follows a {verb}-AzureRm{noun} pattern, and the 0.9.8 doesn’t include Rm. If you are working with 0.9.8, you will have to run the Switch-AzureMode AzureResourceManager command, which will enable the Resource Manager. You don’t have to run that step in the 1.0 Preview version.

Help with cmdlets

You can find detailed help for cmdlets by using the Get-Help cmdlet. To do this, simply enter -Get-Help <cmdlet-name> -Detailed To find a list of cmdlets with a help synopsis enter:

PS C:> Get-Command-Module AzureRM.Resources | Get-Help | Format-Table Name, Synopsis

Log in to Azure

Before you begin working you need to log in to your Azure account. To do this, use the Login-AzureRmAccount cmdlet. In PowerShell versions earlier than 1.0, you will need to use Add-AzureAccount.

This cmdlet will ask for your Azure account login information. After logging in, your account settings will be available to download to Azure PowerShell. Your account settings need to be refreshed periodically because they expire after some time. To refresh the settings, simply run Login-AzureRmAccount, which is required by the Resource Manager modules, anyway.

When deploying a resource, you’ll need to identify where you want to host it. Different regions support different resource types. You will have to find out which regions support the types of resources you are trying to use. To effectively deploy a resource, you should create them in the same region, even though resource groups may have resources spread out in different locations. You may also want to have your database in the same location as the app that is accessing it. To find out which locations support every resource type, use the cmdlet Get-AzureRmResourceProvider

When you run Get-AzureRmResourceProvider you will see a small table with ProviderNamespace and RegistrationState ResourceTypes. ProviderNamespace is a list of related resource types. These will typically match the services you wish to generate in Azure. IF you want to use a resource provider that isn’t registered, you can register it by running the cmdlet Register-AzureRmResourceProvider and state the provider namespace you want to register.  You can find more information about a provider by stating that specific namespace.

For example, you can run Get-AzureRmResource Provider –ProviderNamespace <namespace name> which will show you the RegistrationState, ResourceTypes, and locations.

To limit your search results to display just a list of supported locations, you can run

((Get-AzureRmResourceProvider -Provider Namespace <namespace name>).ResourcTypes | Where-Object ResourceTypeName –eq sites).Locations

If you’re running this at home, you might see different results than at work. A network administrator for your company could have implemented a policy that limits the regions that can be used in the subscription, or there may be other restrictions related to your country for tax purposes.

Create a new resource group

A resource group provides an area or container for all of your solution’s resources that share the same lifecycle. To create one, run New-AzureRmResourceGroup

This cmdlet uses the Name to state a name for the resource group, and Location will state its location. For example, by running New-AzureRmResourceGroup –Name Test1 – Location “East US” you will now have a resource for the Eastern U.S. region.

Find the API versions for your resources

When using a template, you need to specify which API version you wish to use after you create a new resource. The API versions correlate to the versions of REST API functions that the resource provider deploys. Newer versions of REST API will be released as resource providers offer more features. This is why the version of the API you state in the template will affect the properties available as you create the template.

Now that you’ve had a glimpse into some tips and tricks for using PowerShell cmdlets in Azure, you can go on to create your templates and resource groups. Don’t forget to get the most current API versions for your resources.

With Azure, you can gain scalable and durable cloud storage, backup, and recovery solutions to satisfy all of your data needs. Backed by Agile IT’s superior technical expertise and excellent customer satisfaction, you can improve speed of access, maximize availability, minimize downtime, and much more. To learn more about how AgileDataCenter Azure can help you reap the full rewards of Azure, read on here!

This post has matured and its content may no longer be relevant beyond historical reference. To see the most current information on a given topic, click on the associated category or tag.

Related Posts

Ensure Microsoft 365 Backup Data Integrity

Ensuring Data Integrity During Backups in Microsoft 365

Discover strategies to maintain data integrity during Microsoft 365 backups. Pevent corruption, ensure reliability, and meet compliance standards.

Nov 7, 2025
4 min read
Microsoft 365 Tenant Migration for ITAR Organizations

Microsoft 365 Tenant Migration for ITAR-Regulated Organizations

Ensure compliance with ITAR during Microsoft 365 tenant migrations. Learn how to protect export-controlled data and choose the right cloud environment.

Nov 7, 2025
7 min read
NIST SP 800-171 vs 800-172: Key Differences Explained

Key Differences Between NIST SP 800-171 and NIST SP 800-172

Explore the key differences between NIST SP 800-171 and NIST SP 800-172, including how 800-172 enhances security for protecting Controlled Unclassified Information (CUI) against advanced threats.

Nov 4, 2025
6 min read
Tenant Migrations for DFARS-Covered Entities

Handling Sensitive Data in Tenant Migrations for DFARS-Covered Entities

Learn how to securely manage sensitive data during tenant migrations for DFARS-covered entities. Understand CUI protections, cloud tools, and compliance strategies.

Oct 31, 2025
7 min read
Compliant Tenant Migration for DoD Subcontractors

Compliant Tenant-to-Tenant Migration for DoD Subcontractors

Learn how to execute a secure and compliant Microsoft 365 tenant-to-tenant migration for DoD subcontractors while protecting CUI and meeting DFARS and NIST 800-171.

Oct 27, 2025
8 min read
NIST SP 800-171 Considerations in Microsoft 365 Tenant Migrations

NIST SP 800-171 Considerations in Microsoft 365 Tenant Migrations

Ensure compliance with NIST 800-171 when migrating Microsoft 365 tenants. Learn how to secure CUI, meet control requirements, and reduce migration risks.

Oct 27, 2025
7 min read

Ready to Secure and Defend Your Data
So Your Business Can Thrive?

Fill out the form to see how we can protect your data and help your business grow.

Loading...
Secure. Defend. Thrive.

Let's start a conversation

Discover more about Agile IT's range of services by reaching out.

Don’t want to wait for us to get back to you?

Schedule a Free Consultation

Location

Agile IT Headquarters
4660 La Jolla Village Drive #100
San Diego, CA 92122