EN
Deze inhoud is niet beschikbaar in uw taal, maar wel in het Engels.
0 van 1 hebben dit beoordeeld als nuttig - Dit onderwerp beoordelen

Manage Cloud Services Using Windows Azure Cmdlets

Updated: December 11, 2012

You can use the Windows Azure cmdlets to manage the cloud services in your Windows Azure subscription. You can use the cmdlets to do the following:

This section shows you how to create a cloud service to support virtual machines. You can create the cloud service as part of a Windows Azure affinity group or at a specific datacenter location. Use the following cmdlets to create the cloud service:

Before you can use Windows PowerShell to create a cloud service in Windows Azure, you need to:

  • Create a Windows Azure subscription.

  • Create a Windows Azure Storage account for your subscription.

  • Download and install the Windows Azure PowerShell module.

  • Configure a management certificate for the subscription.

  • Configure connectivity to your subscription.

  • If you want to create an affinity group linked to a cloud service, create at least one Windows Azure affinity group.

The New-AzureService cmdlet creates a cloud service for virtual machines. This service is hosted in the specified Windows Azure datacenter when you use the Location parameter, or in a specific affinity group when you use the AffinityGroup parameter. Before you can create a service in an affinity group, you need to create the affinity group. For instructions that use the Windows Azure cmdlets, see Create, configure or delete an affinity group.

To create a cloud service in an affinity group, do the following:

  1. Get a list of available affinity groups in the current Windows Azure subscription and their locations, and store it in a variable. Then, use the variable to display the list. Type:

    PS C:\> $myAG = Get-AzureAffinityGroup
    PS C:\> $myAG
    
    
  2. Review the list to select the affinity group to use with the new service. To select the first affinity group and store its name in a variable, type:

    PS C:\> $targetAGname = $myAG[0].Name
    
  3. Create the service. Type:

    PS C:\> New-AzureService -ServiceName "mySvc01" -AffinityGroup $targetAGname
    
  4. Verify that the service has been created, and is associated with the affinity group you selected. Type:

    PS C:\> Get-AzureService -ServiceName "mySvc01"
    

To create a cloud service in a datacenter location, do the following:

  1. Get a list of datacenter locations, store the list in a variable, and then use the variable to display the list. Type:

    PS C:\> $loc = Get-AzureLocation
    PS C:\> $loc
    
    
  2. Review the list to select the location to use with the new service. To select the first location and store its name in a variable, type:

    PS C:\> $target = $loc[0].Name
    
    
  3. Create the service. Type:

    PS C:\> New-AzureService -ServiceName "mySvc02" -Location $target
    
  4. Verify that the service has been created, and is hosted in the datacenter you selected. Type:

    PS C:\> Get-AzureService -ServiceName "mySvc02"
    
TipTip
To get a complete list of services associated with the current subscription, use the Get-AzureService cmdlet with no parameters.

This section shows you how to remove a cloud service from Windows Azure. Use the following cmdlets to remove the cloud service:

Before you can use Windows PowerShell to remove a cloud service in Windows Azure, you need to:

  • Create a Windows Azure subscription.

  • Create a Windows Azure Storage account for your subscription.

  • Download and install the Windows Azure PowerShell module.

  • Configure a management certificate for the subscription.

  • Configure connectivity to your subscription.

The Remove-AzureService cmdlet removes a cloud service from the current Windows Azure subscription, which deletes the service. Before a service can be removed, all virtual machines and deployments associated with that service must be removed.

To remove a cloud service, do the following:

  1. Get a list of cloud services associated with the current subscription, store the list in a variable, and then display the list. Type:

    PS C:\> $mysvcs = (Get-AzureService).ServiceName
    PS C:\> $mysvcs
    
    
    TipTip
    Tip: To get a list of all the services that are not associated with an affinity group, type:
    PS C:\> Get-AzureService | Where-object {$_.AffinityGroup -ne $null}

  2. Review the list to select the service you want to remove. Get the service from the variable you created in the last step and store it in a new variable. For example, to select the second service in the list, type:

    PS C:\> $target = $mysvcs[1]
    
  3. Remove the service. Type:

    PS C:\> Remove-AzureService -ServiceName $target
    
    
  4. Verify that the service has been removed. Type:

    PS C:\> Get-AzureService
    

This section shows you how to update the configuration of a cloud service in Windows Azure. Use the following cmdlets to update the cloud service:

Before you can use Windows PowerShell to update a cloud service in Windows Azure, you need to:

  • Create a Windows Azure subscription.

  • Create a Windows Azure Storage account for your subscription.

  • Download and install the Windows Azure PowerShell module.

  • Configure a management certificate for the subscription.

  • Configure connectivity to your subscription.

The Set-AzureService cmdlet lets you update the label and description of a cloud service in the current Windows Azure subscription. You cannot use the Set-AzureService cmdlet to change the service name because the service name can be set only when you deploy the service.

To update a cloud service, do the following:

  1. Get a list of the cloud services in the current subscription, formatted as a table and including the

    PS C:\> Get-AzureService | Format-Table -auto ServiceName, Label, Description
    
  2. Review the list to find the cloud service you want to update. Then, get a service in the list and store the object it returns in a new variable. For example, to select the first service and store it in a variable named $target, type:

    PS C:\> $target = Get-AzureService[0]
    
  3. Update the new label and description of the service you selected in the previous step. For example, to label the service as deprecated and provide an explanation, type:

    PS C:\> $target | Set-AzureService -Label "Deprecated" -Description "This service is deprecated. Do not use for new deployments."
    
  4. Verify that service has been updated. Type:

    PS C:\> Get-AzureService
    

This section shows you how to move the deployments in a Windows Azure cloud service between staging and production environments. Use the following cmdlets to move the deployments:

Before you can use Windows PowerShell to move deployments in Windows Azure, you need to:

  • Create a Windows Azure subscription.

  • Create a Windows Azure Storage account for your subscription.

  • Download and install the Windows Azure PowerShell module.

  • Configure a management certificate for the subscription.

  • Configure connectivity to your subscription.

The Move-AzureDeployment cmdlet moves the production and staging deployments of a cloud service in the current Windows Azure subscription by swapping the virtual IP addresses of the two environments. Services with virtual machines do not have separate staging and production slots.

When you swap deployments, the deployment names, labels and descriptions remain unchanged, which can create confusion. For example, if your staging deployment includes "staging" in the name, and you swap the deployment with production, the new production deployment will continue to have "staging" in the name.

To swap deployments, do the following:

  1. Get a list of the cloud services in the current subscription. Type:

    PS C:\> Get-AzureService
    
  2. For example, to move a service named myRoleSvc01 between staging and production, type:

    PS C:\> Move-AzureDeployment -ServiceName "myRoleSvc01"
    

If you want to use the Windows Azure Management Portal to do these tasks, see How to Manage Cloud Services

Vindt u dit nuttig?
(1500 tekens resterend)

Community-inhoud

Toevoegen
© 2013 Microsoft. Alle rechten voorbehouden.
facebook page visit twitter rss feed newsletter