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-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 –ProviderNamespacewhich 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).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

Risks of not using a CMMC RPO

The Risks of Not Using a CMMC RPO for Compliance and Certification Readiness

A CMMC RPO helps organizations prepare for certification and avoid compliance failures. Learn why working with an RPO is essential for achieving CMMC compliance.

Mar 20, 2025
8 min read
CMMC 2.0 Require GCC High for Compliance

Does CMMC 2.0 Require GCC High for Compliance?

Does CMMC 2.0 require GCC High? Learn the cloud options for compliance, data security, and protecting CUI under NIST 800-171 and DFARS.

Mar 17, 2025
10 min read
Office 365 License Comparison: Business Plans Vs. E5, E3 and E1

CMMC RPO vs a C3PAO: Understanding Their Roles in Compliance

Understanding the difference between an RPO and a C3PAO is crucial for CMMC compliance. Learn why they should be separate and how an RPO helps prepare for certification.

Mar 15, 2025
6 min read
Can You Meet CMMC with Google Workspace?

Can You Meet CMMC with Google Workspace?

Is Google Workspace CMMC compliant? Learn about its DFARS, NIST 800-171, and ITAR limitations and how migrating to GCC High ensures full compliance.

Mar 4, 2025
7 min read
Is Maintaining a GCC High Tenant Worth It for Non-Government

Evaluating the Need for a GCC High Tenant in Non-Government Organizations

Explore whether maintaining a GCC High tenant is necessary for organizations not involved in government work. Understand the pros and cons, costs, and compliance considerations.

Feb 25, 2025
7 min read
Top 10 Reasons to Partner with an MSP for Security and Compliance

Top 10 Reasons to Partner with an MSP for Security and Compliance

Discover why partnering with an MSP for security and compliance is critical for organizations navigating FAR CUI and CMMC requirements.

Feb 21, 2025
8 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

Secure. Defend. Thrive.

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

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

Schedule a Free Consultation