GithubHelp home page GithubHelp logo

azure-powershell's Introduction

AzureIcon PowershellIcon Microsoft Azure PowerShell

This repository contains PowerShell cmdlets for developers and administrators to develop, deploy, administer, and manage Microsoft Azure resources.

The Az PowerShell module is preinstalled in Azure Cloud Shell.

Modules

The following table contains a list of the Azure PowerShell rollup modules.

Description Module Name PowerShell Gallery Link
Azure PowerShell Az Az
Azure PowerShell with preview modules AzPreview AzPreview

For a complete list of the modules found in this repository, see Azure PowerShell Modules.

Installation

PowerShell Gallery

Run the following command in a PowerShell session to install the Az PowerShell module:

Install-Module -Name Az -Scope CurrentUser -Repository PSGallery -Force

The latest version of PowerShell 7 is the recommended version of PowerShell for use with the Az PowerShell module on all platforms including Windows, Linux, and macOS. This module also runs on Windows PowerShell 5.1 with .NET Framework 4.7.2 or higher.

The Az module replaces AzureRM. You should not install Az side-by-side with AzureRM.

If you have an earlier version of the Azure PowerShell module installed from the PowerShell Gallery and would like to update to the latest version, run the following command in a PowerShell session:

Update-Module -Name Az -Scope CurrentUser -Force

Update-Module installs the new version side-by-side with previous versions. It does not uninstall the previous versions.

For more information on installing Azure PowerShell, see the installation guide.

Usage

Log into Azure

To connect to Azure, use the Connect-AzAccount cmdlet:

# Opens a new browser window to log into your Azure account.
Connect-AzAccount

# Log in with a previously created service principal. Use the application ID as the username, and the secret as password.
$Credential = Get-Credential
Connect-AzAccount -ServicePrincipal -Credential $Credential -TenantId $TenantId

To log into a specific cloud (AzureChinaCloud, AzureCloud, AzureUSGovernment), use the Environment parameter:

# Log into a specific cloud, for example the Azure China cloud.
Connect-AzAccount -Environment AzureChinaCloud

Session context

A session context persists login information across Azure PowerShell modules and PowerShell instances. Use the Get-AzContext cmdlet to view the context you are using in the current session. The results contain the Azure tenant and subscription.

# Get the Azure PowerShell context for the current PowerShell session
Get-AzContext

# Lists all available Azure PowerShell contexts in the current PowerShell session
Get-AzContext -ListAvailable

To get the subscriptions in a tenant, use the Get-AzSubscription cmdlet:

# Get all of the Azure subscriptions in your current Azure tenant
Get-AzSubscription

# Get all of the Azure subscriptions in a specific Azure tenant
Get-AzSubscription -TenantId $TenantId

To change the subscription that you are using for your current context, use the Set-AzContext cmdlet:

# Set the Azure PowerShell context to a specific Azure subscription
Set-AzContext -Subscription $SubscriptionName -Name 'MyContext'

# Set the Azure PowerShell context using piping
Get-AzSubscription -SubscriptionName $SubscriptionName | Set-AzContext -Name 'MyContext'

For details on Azure PowerShell contexts, see Azure PowerShell context objects.

Discovering cmdlets

Use Get-Command to discover cmdlets within a specific module, or cmdlets that follow a specific search pattern:

# List all cmdlets in the Az.Accounts module
Get-Command -Module Az.Accounts

# List all cmdlets that contain VirtualNetwork in their name
Get-Command -Name '*VirtualNetwork*'

# List all cmdlets that contain VM in their name in the Az.Compute module
Get-Command -Module Az.Compute -Name '*VM*'

Cmdlet help and examples

To view the help content for a cmdlet, use the Get-Help cmdlet:

# View basic help information for Get-AzSubscription
Get-Help -Name Get-AzSubscription

# View the examples for Get-AzSubscription
Get-Help -Name Get-AzSubscription -Examples

# View the full help for Get-AzSubscription
Get-Help -Name Get-AzSubscription -Full

# View the online version of the help from https://learn.microsoft.com for Get-AzSubscription
Get-Help -Name Get-AzSubscription -Online

For detailed instructions on using Azure PowerShell, see the getting started guide.

Reporting Issues and Feedback

Issues

If you find any bugs when using Azure PowerShell, file an issue in our GitHub repo. Fill out the issue template with the appropriate information.

Alternatively, see Azure Community Support if you have issues with Azure PowerShell or Azure services.

Feedback

If there is a feature you would like to see in Azure PowerShell, use the Send-Feedback cmdlet, or file an issue in our GitHub repo.

Contributing

For details on contributing to this repository, see the contributing guide and the Azure PowerShell Developer Guide.

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.

When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repositories using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

Telemetry

Azure PowerShell collects telemetry data by default. Microsoft aggregates collected data to identify patterns of usage to identify common issues and to improve the experience of Azure PowerShell. Microsoft Azure PowerShell does not collect any private or personal data. For example, the usage data helps identify issues such as cmdlets with low success and helps prioritize our work. While we appreciate the insights this data provides, we also understand that not everyone wants to send usage data. You can disable data collection with the Disable-AzDataCollection cmdlet. To learn more, see our privacy statement.

Learn More


This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

azure-powershell's People

Contributors

anton-evseev avatar anusapan avatar azdevxps avatar azure-powershell-bot avatar bashahee avatar bethanyzhou avatar blueww avatar captainfanzzz avatar cormacpayne avatar deepakswifty avatar dingmeng-xue avatar emmazhu avatar eshaparmar avatar evgenyagafonchikov avatar gucalder avatar huangpf avatar hyonholee avatar isra-fel avatar markcowl avatar miyanni avatar msjinlei avatar ogail avatar praries880 avatar safeermohammed avatar sergey-shandar avatar sriramvu avatar stankovski avatar veryearly avatar vivsriaus avatar wyunchi-ms avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

azure-powershell's Issues

Bad error with New-AzureResourceGroup when TemplateFile is not found

I was running the following command ...

New-AzureResourceGroup -Name $name -Location $location -TemplateFile $templateFile -siteName $siteName -hostingPlanName $hostingPlanName -siteLocation $location -Force

... and received an error that took awhile to understand:

New-AzureResourceGroup : A parameter cannot be found that matches parameter name 'siteName'.
At C:\Projects\Github\WadeWegner\azure-go-lang-site-extension\scripts\Deploy.ps1:17 char:84
+ ...  $templateFile -siteName $siteName -hostingPlanName $hostingPlanName -siteLocati ...

When I removed the unknown parameters only then did it give this error:

New-AzureResourceGroup : Could not find file 'C:\Windows\system32\Template.json'.
At C:\Projects\Github\WadeWegner\azure-go-lang-site-extension\scripts\Deploy.ps1:17 char:1
+ New-AzureResourceGroup -Name $name -Location $location -TemplateFile $templateFi ...

Turns out, using the Windows PowerShell ISE, I was in the wrong directory and it couldn't fine the $templateFile.

It would be nice if the cmdlets raised on error on the missing TemplateFile rather than erroring on an unknown parameter.

*-AzureAutomationVariable commands have a boolean parameter

The New-AzureAutomationVariable command has a Boolean parameter named -Encrypted. From a PowerShell perspective, it seems more user friendly to change the -Encrypted parameter from a Boolean type to a switch parameter, which is effectively the same thing.

Switch parameters can still be explicitly set to $true or $false using the following syntax:

New-AzureAutomationVariable -Encrypted:$false

Or

New-AzureAutomationVariable -Encrypted:$true

In cases where users prefer to use PowerShell’s simplified switch parameter syntax, they can either omit the parameter, or specify it with no value passed in.

New-AzureAutomationVariable -Encrypted; # Create an encrypted variable

Or

New-AzureAutomationVariable; # Create an unencrypted variable

Recommendation: Change the -Encrypted parameter from a boolean to a switch parameter.

Cheers,
Trevor Sullivan
Microsoft MVP: PowerShell

AzurePS 0.8.13 :: Azure Virtual Machine commands silently fail

Say, for instance, you are running:

  • Windows 8.1
  • Windows Management Framework Core 5.0 November 2014 Preview (PowerShell 5.0)
  • Microsoft Azure PowerShell module version 0.8.13.

And you have the following configuration:

  • You authenticate to Azure using the Add-AzureAccount command from PowerShell, with the -Credential parameter, using an Azure Active Directory (AAD) Organizational Account.
  • The account you authenticate to Azure with has co-administrator access to more than one Azure platform subscription.
  • One of your two subscriptions has a cloud service with an Azure virtual machine provisioned, and running, inside of it.

Finally, you perform the following steps:

  1. You use the Select-AzureSubscription command to select the Azure subscription that does not have the cloud service / virtual machine in it.
  2. You call the Stop-AzureVM or Export-AzureVM commands against the cloud service / virtual machine. (eg. Stop-AzureVM -ServiceName mycloudsvc -Name vm01 -Force;)
  3. No error / exception is thrown, and the command silently returns.
  4. You add the -Verbose parameter to either command, and still, no output is emitted.
  5. You somehow (magically) realize that you have the wrong subscription selected.
  6. You begin ripping your hair out.
  7. You select the correct Azure subscription and proceed normally.

Given the previous scenario, is it possible to thrown an exception when the specified cloud service / virtual machine is not found, for all of the VM-related commands? It seems like poor design to silently fail, without notifying the end user (me) what is [not] occurring in the background, and why, and how to resolve it.

Cheers,
Trevor Sullivan
Microsoft MVP: PowerShell
http://twitter.com/pcgeek86
http://trevorsullivan.net

New-AzureVM returns location error when creating VM from Linux image in gallery

New-AzureVM -ServiceName $serviceName -VMs (( New-AzureVMConfig -Name $debugVMName -InstanceSize Small -ImageName c290a6b031d841e09f2da759bbabe71f__Oracle-Linux-6 | Add-AzureProvisioningConfig -Linux -LinuxUser test -Password "Test123!"  |  Set-AzureEndpoint -Name "SSH" -LocalPort "22" -PublicPort "22" -Protocol "tcp"  ))

$serviceName is a service in affinity group in West US
The commands return error:
New-AzureVM : BadRequest: The location or affinity group East Asia of the storage account where the source image c290a6b031d841e09f2da759bbabe71f__Oracle-Linux-6 resides is not in the same location or affinity group as the
specified cloud service. The source image must reside in a storage account that has the same affinity group or location as the cloud service West US.

But if you check the location of image c290a6b031d841e09f2da759bbabe71f__Oracle-Linux-6, it has multiple locations including West US.

Get-AzureRole does not respect -ErrorAction

In my subscription I have a number of cloud services, a few of them don't have a deployment (just empty services).
If I try to collect info about the cloud service roles, even using -ErrorAction SilentlyContinue to not be blocked by the empty deployments, I still get a terminating error:

Get-AzureService | Get-AzureRole -ErrorAction SilentlyContinue

RoleName : EventSourceInfo.WebService
InstanceCount : 2
DeploymentID :
ServiceName :
OperationDescription : Get-AzureRole
OperationId :
OperationStatus : Succeeded

Get-AzureRole : ResourceNotFound: No deployments were found.
At line:1 char:20

  • Get-AzureService | Get-AzureRole -ErrorAction SilentlyContinue
  •                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : NotSpecified: (:) [Get-AzureRole], CloudException
    • FullyQualifiedErrorId : Microsoft.WindowsAzure.CloudException,Microsoft.WindowsAzure.Commands.ServiceManagement.HostedServices.GetAzureRoleCommand

Anyway if I use Get-AzureDeployment everything works as expected:

Get-AzureService | Get-AzureDeployment -ErrorAction SilentlyContinue | select DeploymentName

DeploymentName

deployment 1
deployment 2

Get-AzureResourceGalleryTemplate doesn't like to filter...

This returns a template from the gallery that has CategoryIds...
PS C:> Get-AzureResourceGroupGalleryTemplate -Identity Microsoft.WebSiteDeploy.0.2.5-preview

This should also return that template, but doesn't...
PS C:> Get-AzureResourceGroupGalleryTemplate | Where-Object {$_.CategoryIds -like "show"}

I tried a few other broader filters and get the same result.

New-AzureSchedulerStorageQueueJob ignores StorageQueueMessage parameter

The body of storage queue jobs created with the cmdlet New-AzureSchedulerStorageQueueJob is always empty, regardless of the value set for the StorageQueueMessage parameter.

In Microsoft.WindowsAzure.Commands.Utilities.Scheduler.SchedulerMgmntClient::CreateStorageJob, it looks like the created message is referencing the Body property from the PSCreateJobParams object, when it should be using StorageQueueMessage.

The StorageQueueMessage parameter is handled correctly in the Set-AzureSchedulerStorageQueueMessage cmdlet, so a workaround is to create the job with New- and then update it with the correct storage queue message using Set-.

Set-AzureVMImageDataDiskConfig can not add multiple data disks.

I'm trying to add the VM image with the following script. However, disk1 configuration was replaced from disk2 configuration.
Because, Set-AzureVMImageDataDiskConfig search for existing disk configuration by disk name. If AddAzureVMImageParamSet mode, it search by MediaLink?

...

$config = New-AzureVMImageDiskConfigSet | 
          Set-AzureVMImageOSDiskConfig -OS Windows -HostCaching ReadWrite -OSState Specialized -MediaLink $osUri |
          Set-AzureVMImageDataDiskConfig -Lun 1 -HostCaching None -MediaLink $data1Uri  |
          Set-AzureVMImageDataDiskConfig -Lun 2 -HostCaching None -MediaLink $data2Uri

Add-AzureVMImage -ImageName foo -DiskConfig $config -ShowInGui

Thanks.

Select-Object works correctly only when a cmdlet is wrapped in parentheses

Context:

StorSimple service contains 4 StorageAccountCredential objects, we are trying to select the first one, and use that to create a new VolumeContainer object.

Failure scenario:

$sacToUse = Get-AzureStorSimpleStorageAccountCredential | Select-Object -First 1 -Wait
$sacToUse | New-AzureStorSimpleDeviceVolumeContainer -DeviceName avirupch_app3 -Name vc_11 -BandWidthRate 256 –WaitForComplete

$sacToUse is a list of all 4 StorageAccountCredential objects instead of only the first one, and when piped to the second cmdlet it results in the latter being called once for each object, that is total 4 times.

Succeess scenario:

$sacToUse2 = (Get-AzureStorSimpleStorageAccountCredential) | Select-Object -First 1 -Wait
$sactoUse2 | New-AzureStorSimpleDeviceVolumeContainer -DeviceName avirupch_app3 -Name vc_12 -BandWidthRate 256 –WaitForComplete

After wrapping the first cmdlet in parentheses, $sacToUse2 now returns only the first object, and thus the second cmdlet is also called once.

Test-AzureTrafficManagerDomainName: Please deprecate in favor of Test-AzureName

The Azure PowerShell module (I'm running 0.8.13) has a Test-AzureName command that tests the availability and validity of globally-unique DNS names for:

  • Azure Cloud Services
  • Azure Storage Accounts
  • Azure ServiceBus Namespaces
  • Azure Websites

However, the Azure Traffic Manager feature has a separate command dedicated to testing the availability of globally-unique Traffic Manager DNS names, called ``Test-AzureTrafficManagerDomainName. Having a separate command, just for Traffic Manager, is inconsistent from an end user experience, and the functionality it offers should be merged into the Test-AzureName` command.

Feel free to e-mail me with any questions or input on this topic.

Cheers,
Trevor Sullivan
Microsoft MVP: PowerShell
http://trevorsullivan.net
http://twitter.com/pcgeek86

Get-AzureAutomationAccount doesn't throw an exception for an invalid Azure location

Scenario

When you run the Get-AzureAutomationAccount command, and specify an invalid value for the -Name parameter (eg. a non-existent account), an exception is thrown, pointing out that the specified account name does not exist.

However, when you specify the -Location parameter, and pass in an invalid Azure location, or no accounts exist in the specified region / location, then no exception is thrown.

image

Expected Behavior

My expectation would be that, in all circumstances, if an invalid name is specified, or an invalid region is specified, or if no accounts exist in a specific region, then an exception should be thrown.

If the command is executed without any parameters, then no exception should be thrown, since the user was not asking for a specific account, or accounts from a specific Azure region.

Thanks for your consideration.

Cheers,
Trevor Sullivan
Microsoft MVP: PowerShell

Websites commands cache is broken

There is a caching capability for the Websites commands (specifically caching of websites) but currently it is broken and is not used (throws a serialization exception).

Add-AzureAccount doesn't like credentials with &

If I pass a creds object that has a password with an ampersand, the password seems to get munged and auth fails... try:

$securepass = ConvertTo-SecureString -string 'foobar&d' -Force -AsPlainText
$creds = New-Object System.Management.Automation.PSCredential('[email protected]', $securepass)
Add-AzureAccount -credential $creds
(note using Add-AzureAccount interactively with the same set of creds works fine)


Import-AzurePublishSettingsFile throws CryptographicException when called from Bamboo OnDemand

I am trying to automate Azure deployment from a Bamboo OnDemand Amazon EC2 Elastic Instance. Unfortunately, I've hit a bump in the road and I'm not quite sure why or how to solve it.

As an example, I tried the following script:

Write-Output "Importing Azure Module"
Import-Module Azure

Try {
    Write-Output "Importing Azure Publish Settings"
    Import-AzurePublishSettingsFile "C:\Users\Bamboo\azure2.publishsettings" -ErrorAction Stop
}
Catch {
    Write-Output "An error occurred"

    Write-Output $_.Exception.Message
    Write-Output $_.Exception.ItemName
    Write-Output $_.Exception.StackTrace

    exit 1
}

The exception info:

27-Nov-2014 19:01:05    Importing Azure Module
27-Nov-2014 19:01:05    Importing Azure Publish Settings
27-Nov-2014 19:01:05    An error occurred
27-Nov-2014 19:01:05    An internal error occurred.
27-Nov-2014 19:01:05    
27-Nov-2014 19:01:05       at System.Security.Cryptography.CryptographicException.ThrowCryptographicException(Int32 hr)
27-Nov-2014 19:01:05       at System.Security.Cryptography.X509Certificates.X509Utils._LoadCertFromBlob(Byte[] rawData, IntPtr password, UInt32 dwFlags, Boolean persistKeySet, SafeCertContextHandle& pCertCtx)
27-Nov-2014 19:01:05       at System.Security.Cryptography.X509Certificates.X509Certificate.LoadCertificateFromBlob(Byte[] rawData, Object password, X509KeyStorageFlags keyStorageFlags)
27-Nov-2014 19:01:05       at System.Security.Cryptography.X509Certificates.X509Certificate2..ctor(Byte[] rawData, String password)
27-Nov-2014 19:01:05       at Microsoft.WindowsAzure.Commands.Utilities.Common.PublishSettingsImporter.PublishSubscriptionToAzureSubscription(ProfileClient azureProfileClient, PublishDataPublishProfile profile, PublishDataPublishProfileSubscription s, String environment)
27-Nov-2014 19:01:05       at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
27-Nov-2014 19:01:05       at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
27-Nov-2014 19:01:05       at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
27-Nov-2014 19:01:05       at Microsoft.WindowsAzure.Commands.Common.ProfileClient.ImportPublishSettings(String filePath, String environmentName)
27-Nov-2014 19:01:05       at Microsoft.WindowsAzure.Commands.Profile.ImportAzurePublishSettingsCommand.ImportFile(String fileName)
27-Nov-2014 19:01:05       at Microsoft.WindowsAzure.Commands.Profile.ImportAzurePublishSettingsCommand.ExecuteCmdlet()
27-Nov-2014 19:01:05       at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord()
27-Nov-2014 19:01:05    Failing task since return code of [powershell -ExecutionPolicy bypass -Command C:\Users\Bamboo\AppData\Local\Temp\2457601-2555906-2752561-ScriptBuildTask-1993266622499637567.ps1] was 1 while expected 0
27-Nov-2014 19:01:05    Finished task 'Deploy' with result: Failed

This script is invoked through the build system with the following command:

powershell -ExecutionPolicy bypass -Command C:\Users\Bamboo\AppData\Local\Temp\2457601-2555906-2752561-ScriptBuildTask-1993266622499637567.ps1

The weird part is that, if I RDP onto the VM with the bamboo user and run the Import-AzurePublishSettingsFile "C:\Users\Bamboo\azure2.publishsettings" manually every following execution of the build script succeeds and prints out the result of the Import-AzurePublishSettingsFile call.

In order to save costs, the build server is set on a schedule to shut down between 8 PM and 7 AM which means that currently someone has to log on onto the virtual machine every day and run the command manually before any deployment succeeds. It's understandable that this is becoming a burden on our deployment process.

I know that Bamboo might be a factor in this, but I would like to understand what could be the problem and why this could occur. Could it be something with the way the script is invoked, is there a PowerShell command I must run to elevate certain permissions, ...

Thanks

Calling Set-AzureServiceDiagnosticsExtension with Role parameter fails

I'm trying to set Azure diagnostics on a deployed cloud service using v0.8.11 Azure Powershell cmdlets and the Set-AzureServiceDiagnosticsExtension command:

Set-AzureServiceDiagnosticsExtension -StorageContext $storageContext -DiagnosticsConfigurationPath $diagnosticsConfiguration.FullName -ServiceName $serviceName -Slot Production -Role "MyService.Web"-Verbose

Doing so I get the following error

Exception: Microsoft.WindowsAzure.CloudException: BadRequest: The extension ID
MyService.Web-PaaSDiagnostics-Production-Ext-0 is invalid.
   at Microsoft.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task)
   at Microsoft.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccess(Task
task)
   at Microsoft.WindowsAzure.HostedServiceOperationsExtensions.AddExtension(IHo
stedServiceOperations operations, String serviceName,
HostedServiceAddExtensionParameters parameters)
   at Microsoft.WindowsAzure.Commands.ServiceManagement.Extensions.ExtensionMan
ager.AddExtension(HostedServiceAddExtensionParameters extensionInput)
   at Microsoft.WindowsAzure.Commands.ServiceManagement.Extensions.ExtensionMan
ager.InstallExtension(ExtensionConfigurationInput context, String slot,
ExtensionConfiguration extConfig)
   at Microsoft.WindowsAzure.Commands.ServiceManagement.Extensions.SetAzureServ
iceDiagnosticsExtensionCommand.ExecuteCommand()
   at Microsoft.WindowsAzure.Commands.ServiceManagement.Extensions.SetAzureServ
iceDiagnosticsExtensionCommand.OnProcessRecord()
   at Microsoft.WindowsAzure.Commands.Utilities.Common.CloudBaseCmdlet`1.Proces
sRecord()
   at System.Management.Automation.Cmdlet.DoProcessRecord()
   at System.Management.Automation.CommandProcessor.ProcessRecord()
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorExcep
   tion
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorExceptio
   n,UpdateDiagnosticsBuildStep.ps1

It works when I don't use the "-Role" parameter but then I have to call Remove-AzureServiceDiagnosticsExtension for each role prior to calling the Set command which adds 2-3 minutes per role to the script execution time.

The Role parameter matches my role name in the Azure Cloud Service. Am I doing something wrong or is this a bug?

Add-AzureAccount doesn't like credentials with &

If I pass a creds object that has a password with an ampersand, the password seems to get munged and auth fails... try:

$securepass = ConvertTo-SecureString -string 'foobar&d' -Force -AsPlainText
$creds = New-Object System.Management.Automation.PSCredential('[email protected]', $securepass)
Add-AzureAccount -credential $creds
(note using Add-AzureAccount interactively with the same set of creds works fine)


New-AzureVNetGateway :: Confusing error message for invalid GatewayType

When you specify an invalid value for the -GatewayType parameter on the New-AzureVNetGateway command, the resulting error message is very confusing, and doesn't help the end user discover what is wrong.

  • Azure PowerShell module 0.8.12
  • PowerShell 5.0 November 2014 Preview

New-AzureVNetGateway : BadRequest: The specified request content was not valid and could not be deserialized.

Cheers,
Trevor Sullivan
Microsoft MVP: PowerShell

Feature request: Cmdlets to operate on entities in table storage

Summary

Table storage cmdlets currently only support operations at the table level. I would like cmdlets for entity-level operations (more or less a wrapper for the operations available in Microsoft.WindowsAzure.Storage.Table.TableOperation)

Scenarios

Scenario A

My service is deployed with a bug which causes it to write a hundred thousand corrupted
rows to table storage overnight. I want to write a quick ps script to either remove or edit the bad rows the next morning.

Implementation

I would like the Azure team to implement these cmdlets.

I've hacked together a cmdlet for deleting entities to solve issues similar to the one mentioned above, but I don't currently have a business need to implement the remaining operations (and I'm assuming that Azure will not officially release the cmdlets until all operations are supported. Correct me if I'm wrong). If something changes and I decide to implement the rest I'll let you know.

Get-AzureAccount Parameters vs. Properties consistency

Get-AzureAccount cmdlet returns a property Id which has the name of the account "[email protected]". However, Get-AzureAccount has -Name parameter used to retrieve the account "[email protected]" which is totally confusing and inconsistent. The same parameter -Name with Remove-AzureAccount which trigger an error when to pipe Get-AzureAccount to Remove-AzureAccount
dd
What I suggest here is to either change the property name returned from Get-AzureAccount from Id to Name, or change the Parameter -Name to -Id

Get-AzureTrafficManager returns two different object types (that represent the same object)

Background

When you run the Get-AzureTrafficManager command, without any parameters, the objects that are returned are of the type Microsoft.WindowsAzure.Commands.TrafficManager.Models.SimpleProfile.

image

When you run the Get-AzureTrafficManager command with the -Name parameter, to retrieve a specific Traffic Manager profile, the object type that is returned is Microsoft.WindowsAzure.Commands.TrafficManager.Models.ProfileWithDefinition.

image

Problem Statement

By using the Get-Member command, shown in the screenshots above, you will notice the lack of properties on the SimpleProfile type.

As with certain other characteristics of the Azure PowerShell module, this does not follow solid PowerShell design principles. A typical end user of PowerShell would expect to be able to run Get-AzureTrafficManagerProfile | Select-Object -Property * to see all of the property values on the objects returned from the command. However, because two different object types are being returned, that ultimately represent the same object (an Azure Traffic Manager Profile), the simplified view is being returned, even when the Select-Object command is specified.

Scenario

Consider the following scenario: You want to retrieve a list of all your Azure Traffic Manager Profiles, but only want to see the properties DomainName and LoadBalancingMethod. Because the SimpleProfile object does not offer the LoadBalancingMethod property, you would have to:

  1. Call Get-AzureTrafficManagerProfile, to retrieve the "simple" definitions of all the Traffic Manager profiles
  2. Iterate over each Traffic Manager profile
  3. Call Get-AzureTrafficManagerProfile again, for each Profile, with the -Name parameter
  4. Filter each ProfileWithDefinition for the DomainName and LoadBalancingMethod properties

As you can see, this process is significantly more challenging than simply calling:

Get-AzureTrafficManagerProfile | Select-Object -Property DomainName, LoadBalancingMethod;

Type Formatting

While technically it's perfectly valid for this behavior to occur, the behavior described above goes somewhat against the design principles of PowerShell.

In fact, PowerShell was designed from the very beginning to handle this type of scenario. It's called PowerShell "type formatting," and at a high level, it's basically an XML file, with a .ps1xml file extension, that offers up "hints" to PowerShell to help it figure out how to display an object. Therefore, if an object has 10 properties, but only 4 or 5 of them are most commonly cared about, then only those properties will be shown by default. However, if the user pipes the command into a formatting command such as Format-Table, Format-List, or even Select-Object, the user gains control over which properties are displayed (or "selected" / filtered).

Actionable Item

The suggested "PowerShell-friendly" corrective action for this implementation is to return a single object type, to represent an Azure Traffic Manager Profile, regardless of whether or not the -Name parameter is present. Implement a "type formatting" .ps1xml file in the Azure PowerShell module, that hints/instructs PowerShell on how to display the Traffic Manager object by default, but ensure that the user has control to select all, or some, of the properties that they so desire, without being forced to retrieve a specific profile, using the -Name parameter.

Please reach out to me for clarification if it is required, otherwise I will trust that this post is well-understood.

Cheers,
Trevor Sullivan
Microsoft MVP: PowerShell
http://twitter.com/pcgeek86
http://trevorsullivan.net

Get-AzureResourceGroupLog timestamp issue

The Get-AzureResourceGroupLog cmdlet does not expose a time constraints, thus generates them in code. The code seems to use local Computer culture to generate time constraints. This leads to wrong dates. Here is an example produced on a computer with bg-BG locale:

PS C:\Users\Anton> Get-AzureResourceGroupLog -Name "rg-demo-rdr" -All -Debug -Verbose

DEBUG: 21:20:48 - GetAzureResourceGroupLogCommand begin processing with ParameterSet 'All'.
DEBUG: 21:20:55 - using account id 'xxxxxxx'...
DEBUG: ============================ HTTP REQUEST ============================

HTTP Method: GET
Absolute Uri:
https://management.azure.com/subscriptions/xxxxxxxx-xxxxxx-xxxx/providers/microsoft.insights/eventtypes/management/values?api-version=2014-04&$filter=resourceGroupName eq 'rg-demo-rdr' and &eventTimestamp ge '15.11.2014 г. 20:20:58' and &eventTimestamp le '12.02.2015 г. 20:20:58' and
Headers:
Accept: application/json
Body:

Add-AzureAccount fails with certain accounts.

when i use the Add-AzureAccount the command fails with a cryptic message

PS C:\Users\al6905> Add-AzureAccount
Add-AzureAccount : Account1 Ids do not match.
At line:1 char:1
+ Add-AzureAccount
+ ~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [Add-AzureAccount], ArgumentException
    + FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.Profile.AddAzureAccount

Extra Info

  • The account email address is xxxxxxxxxxxxxxxxxxxxxxxx
  • Tools Version 0.8.13
  • A brief bit of googling returned several similar errors

http://stackoverflow.com/questions/25404430/how-to-use-microsoft-not-organizational-account-with-add-azureaccount

New-Azurewebsite conflicts with non existing sites

New-Azurewebsite throws error: Website with given name [name] already exists.
But i cant see the site(s) in azure portal.
And when i run Get-Azurewebsite it only returns the sites that i actually can see in the portal.
I have also tried to run Remove-Azurewebsite, but these "ghost" sites doesnt get deleted.

someone with same problem?

Possible breaking change Get-AzureVM breaks pipeline with Out-Gridview (#3047)

(reposted from Azure/azure-sdk-tools#3047 - 11/04/2014)

Get-AzureVM breaks pipeline with Out-Gridview. I have Trevor Sullivan confirmed this issue.

This is PowerShell Azure Cmdlets version 0.8.10.1 in PowerShell 4.0.

PS C:> $vm = Get-AzureVM | Out-Gridview -PassThru
Get-AzureVM : The pipeline has been stopped.
At line:1 char:7
•$vm = Get-AzureVM | Out-Gridview -PassThru
• ~~~~~~~~~~~ ◦CategoryInfo : CloseError: (:) [Get-AzureVM], PipelineStoppedException
◦FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.ServiceManagement.IaaS.GetAzureVMCommand Out-Gridview : Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index At line:1 char:21

•$vm = Get-AzureVM | Out-Gridview -PassThru
• ~~~~~~~~~~~~~~~~~~~~~~ ◦CategoryInfo : NotSpecified: (:) [Out-GridView], ArgumentOutOfRangeException
◦FullyQualifiedErrorId : System.ArgumentOutOfRangeException,Microsoft.PowerShell.Commands.OutGridViewCommand

Thanks,
Maximo Trinidad
Microsoft MVP - PowerShell

Add PowerShell command to configure Azure Automation service plan & retrieve usage

The updates to the Azure PowerShell module surrounding the Azure Automation feature are great! A couple of additional commands that would be useful, to help manage customer environments would include:

  • A PowerShell command to retrieve the number of Automation minutes used in the current month
  • A PowerShell command to configure the Azure Automation service plan (Free or Basic)

Cheers,
Trevor Sullivan
Microsoft MVP: PowerShell
http://trevorsullivan.net
http://twitter.com/pcgeek86

Remove-AzureWebsite doesn't remove the GitHub WebHook

I am testing with Powershell for a customer issue. I created a lot sites which linked to same repository.

After that, I run this to remove all the sites. The sites were disappeared but the WebHook URLs left on GitHub.

$i= 0
while ( $i -lt 25)
{
Remove-AzureWebsite -Name "wzhaotest${i}" -Force
$i = $i + 1
}

Thanks,
Wei

Get-HybridConnection NewtonSoft.Json Version4.5.0.0 cannot find file

Hello I'm having this issue:

PS C:\WINDOWS\system32> get-hybridconnection
get-hybridconnection : Could not load file or assembly 'Newtonsoft.Json, Version=4.5.0.0, Culture=neutral,
PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified.
At line:1 char:1
+ get-hybridconnection
+ ~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Get-HybridConnection], FileNotFoundException
    + FullyQualifiedErrorId : System.IO.FileNotFoundException,Microsoft.HybridConnectionManager.Commands.GetHybridConn
   ection

I found this issue that talks about it on stack overflow:

http://stackoverflow.com/questions/26937504/unable-to-perform-azure-biztalk-hybrid-connection-on-premisis-part

Is there anything to do to resolve this?

I've read this:

http://blog.rthand.com/post/2013/11/04/When-net-assemblies-arent-properly-versioned-odd-errors-happen.aspx

but I do not have JSON.net installed into the gac:

C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC>gacutil /l newtonsoft.jso
n
Microsoft (R) .NET Global Assembly Cache Utility.  Version 4.0.30319.1
Copyright (c) Microsoft Corporation.  All rights reserved.

The Global Assembly Cache contains the following assemblies:

Number of items = 0

Any help is appreciated

Remove-AzureStorageDirectory :: Missing a -Force parameter

The Remove-AzureStorageDirectory command is missing a -Force parameter. If the directory is not empty, then an exception is thrown.

  • Azure PowerShell module version 0.8.12
  • WMF / PowerShell 5.0 November 2014 Preview

Remove-AzureStorageDirectory : The remote server returned an error: (409) Conflict. HTTP Status Code: 409 - HTTP Error Message: The specified directory is not empty.

image

Cheers,
Trevor Sullivan
Microsoft MVP: PowerShell

Azure PS 0.8.12 :: Network Security Group commands missing documentation

The Azure PowerShell commands for managing Network Security Groups are almost completely absent of documentation, except for documentation that is automatically generated by PowerShell.

image

Please ensure that these commands (and all others) are thoroughly documented in the Azure PowerShell module.

Cheers,
Trevor Sullivan
Microsoft MVP: PowerShell

Blob Metadata

While it's possible to upload blobs and set metadata, there doesn't seem to be a way to get blobs based on their metadata.

I'd love to be able to do something like:

Get-AzureStorageBlob -Metadata @{ "Environment" = "Staging" } -Container mycontainer

It doesn't seem possible with the current release. Have I just missed something?

Build fails: too long absolute paths

I cloned azure-powershell project to folder C:\projects\dsc-azure-ext\azure-powershell
And run tools\Build.ps1

The specified path, file name, or both are too long. The fully qualified file name must be less than 
260 characters, and the directory name must be less than 248 characters.

Caused by file TestNewResourceGroupWithTemplateThenGetWithAndWithoutDetails.json in one of the subfolders.

SQL v12 Preview - Start-AzureSqlDatabaseExport doesn't like the connection context

Using the sample "Example 1" in the documentation (https://msdn.microsoft.com/en-us/library/azure/dn546720.aspx), against a v12 preview SQL Azure database server, I am getting this error:

Start-AzureSqlDatabaseExport : Cannot bind parameter 'SqlConnectionContext'. Cannot convert the 
"Microsoft.WindowsAzure.Commands.SqlDatabase.Services.Server.TSqlConnectionContext" value of type 
"Microsoft.WindowsAzure.Commands.SqlDatabase.Services.Server.TSqlConnectionContext" to type 
"Microsoft.WindowsAzure.Commands.SqlDatabase.Services.Server.ServerDataServiceSqlAuth".
At line:10 char:69
+ $exportRequest = Start-AzureSqlDatabaseExport -SqlConnectionContext $SqlCtx -Sto ...
+                                                                     ~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Start-AzureSqlDatabaseExport], ParameterBindingException
    + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.WindowsAzure.Commands.SqlDatabase.Database.Cmdlet.StartAzureSqlDatabaseExport

Here's the code (keys & server names scrubbed):

$StorageName = "SCRUBBED"
$StorageKey = "SCRUBBED"
$BlobName = "SCRUBBED"
$ServerName = "SCRUBBED"
$DatabaseName = "SCRUBBED"
$credential = Get-Credential


$SqlCtx = New-AzureSqlDatabaseServerContext -ServerName $ServerName -Credential $credential
$StorageCtx = New-AzureStorageContext -StorageAccountName $StorageName -StorageAccountKey $StorageKey
$Container = Get-AzureStorageContainer -Name $ContainerName -Context $StorageCtx
$exportRequest = Start-AzureSqlDatabaseExport -SqlConnectionContext $SqlCtx -StorageContainer $Container -DatabaseName $DatabaseName -BlobName $BlobName

Set-AzureVMDscExtension checks local computer for DSC modules

Problem Description: The Set-AzureVMDscExtension command in the Azure PowerShell module, version 0.8.11, is checking the local computer for all of the supporting DSC modules (resources) before deploying the configuration document to the target virtual machine. If the local computer doesn't have all of the DSC resources that are required on the target system, then the command fails.

Expected Behavior: The Set-AzureVMDscExtension` command should not require that DSC resources be present on the local system, prior to deployment of the new/updated VM configuration.

image

VERBOSE: Parsing configuration script: C:\dc01-dsc.ps1
Publish-AzureVMDscConfiguration : Configuration script 'C:\dc01-dsc.ps1' contained parse errors:
At C:\dc01-dsc.ps1:7 char:5

  • Import-DscResource -ModuleName xActiveDirectory,xPendingReboot;
    
  • ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    Unable to load module 'xActiveDirectory': module not found.

NOTE: I found out that the Publish-AzureVMDscConfiguration command is bundling together the DSC modules along with the DSC configuration document, but this should still be an optional configuration. If I pre-stage the DSC resource on the target system using another mechanism, I shouldn't have to bundle them into the Azure DSC ZIP file.

Cheers,
Trevor Sullivan
Microsoft MVP: PowerShell
http://twitter.com/pcgeek86

Save-AzureWebsiteLog The maximum message size quota for incoming messages (65536) has been exceeded

I'm trying to use the Azure powershell Save-AzureWebsiteLog command to get the logs for an azure site. Get the message below

Save-AzureWebsiteLog -Name <*******> -Output .\logs.zip
Save-AzureWebsiteLog : The maximum message size quota for incoming messages (65536) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding
element.
At line:1 char:1

  • Save-AzureWebsiteLog -Name <name removed> -Output .\logs.zip
  • - CategoryInfo          : CloseError: (:) [Save-AzureWebsiteLog], CommunicationException
    - FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.Websites.SaveAzureWebsiteLogCommand
    
    

Is this a known problem, and is there any resolution?

Get-AzureAccount ignores -Name parameter

I've tried 0.8.13 and 0.8.14, both behavior the same way.

TWO PROBLEMS:
a) Get-AzureAccount optionally asks for a Name, but accounts only have an ID, so where am I supposed to find the name?
b) Passing in a name to Get-AzureAccount is supposed to make it return only that account. Instead, it appears to be ignored, as all accounts are returned no matter what name I pass in.

REPRO:

  1. Sign in to multiple Azure accounts (e.g. I’m signed in to an org and MSID account)
  2. Get-AzureAccount

Id Type Subscriptions Tenants
[email protected] User ...
...

[email protected] User ...
...

!) Problem a: Notice that there is no Name property listed in the account, so how do I find it?

  1. Try passing in a particular account’s name (I’m currently assuming it's the same as the ID, e.g. [email protected]):

Get-AzureAccount -Name '[email protected]'

Id Type Subscriptions Tenants
[email protected] User ...
...

[email protected] User ...
...

!) Problem b: It still gave me all accounts. Expected: Either return only the specified account, or return null/exception if an account with that name was not found.

New-AzureStorageShare missing -PassThru parameter

The New-AzureStorageShare command doesn't return a new Storage Share (Microsoft.WindowsAzure.Storage.File.CloudFileShare) object, and doesn't offer a -PassThru parameter either. Therefore, an extra call to Get-AzureFileShare must be made in order to retrieve the object representing the share.

Please add the -PassThru parameter to New-AzureStorageShare to ensure that the new share object can be returned.

Cheers,
Trevor Sullivan
Microsoft MVP: PowerShell
http://twitter.com/pcgeek86
http://trevorsullivan.net

Get-AzureSubscription, TAB completion does not work after pipeline

I can repro this problem on two different machines (both Windows 8.1):
Name : Windows PowerShell ISE Host
Version : 4.0
InstanceId : f3c1119d-3c32-432d-a235-5b3755fe9979
UI : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture : en-US
CurrentUICulture : en-US
PrivateData : Microsoft.PowerShell.Host.ISE.ISEOptions
IsRunspacePushed : False
Runspace : System.Management.Automation.Runspaces.LocalRunspace

If you run Get-AzureSubscription | ? subscr --> TAB nothing happens, the command is used to cycle through available options (SubscriptionId and SubscriptionName in this example).

Intellisense in the ISE also appears to have a problem:
if you run "(Get-AzureSubscription)[0]" the SubscriptionId is returned along with other subscription info, but if you run "(Get-AzureSubscription)[0]." (add the dot to invoke the IntelliSense) I get a completely different list of properties (Account, Environment, Id, Name, Properties).

Anyway if I run "(Get-AzureSubscription)[0] | get-method" then I see the expected properties

TypeName: Microsoft.WindowsAzure.Commands.Profile.Models.PSAzureSubscription

Name MemberType Definition

Equals Method bool Equals(System.Object obj)

GetHashCode Method int GetHashCode()

GetType Method type GetType()

ToString Method string ToString()

Accounts Property Microsoft.WindowsAzure.Commands.Common.Models.AzureAccount[] Accounts {get;set;}
CurrentStorageAccountName Property string CurrentStorageAccountName {get;set;}

DefaultAccount Property string DefaultAccount {get;set;}

Environment Property string Environment {get;set;}

IsCurrent Property bool IsCurrent {get;set;}

IsDefault Property bool IsDefault {get;set;}

SubscriptionId Property string SubscriptionId {get;set;}

SubscriptionName Property string SubscriptionName {get;set;}

SupportedModes Property string SupportedModes {get;set;}

Intellisense for New-AzureVNetGateway parameters not working

Hello,

On the New-AzureVNetGateway command, I was fairly confident that the -GatewayType and -GatewaySKU parameters supported tab/auto-completion via Intellisense, however I'm not seeing this behavior on Azure PowerShell 0.8.11 or 0.8.12, at the very least. Instead, the standard file-system auto-completion appears when you attempt to perform Intellisense / tab completion.

Could you please ensure that the appropriate parameter values are enabled for auto-completion for -GatewayType and -GatewaySKU?

FYI, I'm using the Windows Management Framework Core 5.0 November 2014 Preview.

Cheers,
Trevor Sullivan
Microsoft MVP: PowerShell

Get-AzureResource: Azure SQL Database malformed request.

The Cmdlet sends the wrong request to the Azure API. When I run a tag command via the new portal it sends:

/subscriptions/GUID/resourceGroups/Default-SQL-WestUS/providers/Microsoft.Sql/servers/{servername}/databases/{database}?api-version=2014-04-01

If I make the same request via PowerShell it misses the /servers/ node in the path:

/subscriptions/GUID/resourcegroups/Default-SQL-WestUS/providers/Microsoft.Sql/{servername}/databases/{database}?api-version=2014-04-01

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.