Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Azure rShell命令。现在,经典网站迁移到ARM,我们应该使用ARM命令来完成它。@HBala我们应该使用ARM powershell命令来完成它,我们应该在运行手册中添加powershell脚本。当我们使用该连接时,我们将使用该订阅作为默认订阅。@HBala_Azure_Powershell_Azure Web App Service_Azure Powershell_Azure Automation - Fatal编程技术网

Azure rShell命令。现在,经典网站迁移到ARM,我们应该使用ARM命令来完成它。@HBala我们应该使用ARM powershell命令来完成它,我们应该在运行手册中添加powershell脚本。当我们使用该连接时,我们将使用该订阅作为默认订阅。@HBala

Azure rShell命令。现在,经典网站迁移到ARM,我们应该使用ARM命令来完成它。@HBala我们应该使用ARM powershell命令来完成它,我们应该在运行手册中添加powershell脚本。当我们使用该连接时,我们将使用该订阅作为默认订阅。@HBala,azure,powershell,azure-web-app-service,azure-powershell,azure-automation,Azure,Powershell,Azure Web App Service,Azure Powershell,Azure Automation,rShell命令。现在,经典网站迁移到ARM,我们应该使用ARM命令来完成它。@HBala我们应该使用ARM powershell命令来完成它,我们应该在运行手册中添加powershell脚本。当我们使用该连接时,我们将使用该订阅作为默认订阅。@HBala我们无法在该powershell中将Azure模式切换为ASM,我们应该使用ARM命令更改网站配置,不能使用ASM命令更改。您使用的是什么部署模型?手臂还是经典?您在订阅中的角色分配是什么?@Ramana ARM,并且是所有订阅中的共同管理员角


rShell命令。现在,经典网站迁移到ARM,我们应该使用ARM命令来完成它。@HBala我们应该使用ARM powershell命令来完成它,我们应该在运行手册中添加powershell脚本。当我们使用该连接时,我们将使用该订阅作为默认订阅。@HBala我们无法在该powershell中将Azure模式切换为ASM,我们应该使用ARM命令更改网站配置,不能使用ASM命令更改。您使用的是什么部署模型?手臂还是经典?您在订阅中的角色分配是什么?@Ramana ARM,并且是所有订阅中的共同管理员角色。服务主体作为“参与者”添加到订阅中。
Select-AzureSubscription : The subscription name {nameofsubscription} doesn't exist.
Parameter name: name
At step1_validate:18 char:18
+ 
+ CategoryInfo          : CloseError: (:) [Select-AzureSubscription], ArgumentException
+ FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.Profile.SelectAzureSubscriptionCommand
Select-AzureSubscription -SubscriptionName $defaultSubscriptionname –Default 

Get-AzureSubscription -SubscriptionId 123XXXXXXXXXXXXXXXXXX96eXX58 | Select-AzureSubscription
$subscriptionId = (Get-AzureRmSubscription | Out-GridView -Title 'Select Azure Subscription:' -PassThru).Id
Select-AzureRmSubscription -SubscriptionId $subscriptionId
<# 
This PowerShell script was automatically converted to PowerShell Workflow so it can be run as a runbook.
Specific changes that have been made are marked with a comment starting with “Converter:”
#>
<#
.DESCRIPTION
    To watch php version old in app, and if found turn it off and apply 5.6 

.NOTES
    AUTHOR: HBala
    LASTEDIT: Jan 04, 2018
#>

workflow step1_validate {

# Converter: Wrapping initial script in an InlineScript activity, and passing any parameters for use within the InlineScript
# Converter: If you want this InlineScript to execute on another host rather than the Automation worker, simply add some combination of -PSComputerName, -PSCredential, -PSConnectionURI, or other workflow common parameters (http://technet.microsoft.com/en-us/library/jj129719.aspx) as parameters of the InlineScript
inlineScript {
    $connectionName = "AzureRunAsConnection"
    $myResourceGroupName = "DevstorageRG"
    $defaultSubscriptionname = "StandardDevStaging"
    $newPhpVersion = "5.6"

    try
    {
        # Get the connection "AzureRunAsConnection "
        $servicePrincipalConnection=Get-AutomationConnection -Name $connectionName         

        "Logging in to Azure..."
        Add-AzureRmAccount `
    -ServicePrincipal `
    -TenantId $servicePrincipalConnection.TenantId `
    -ApplicationId $servicePrincipalConnection.ApplicationId `
    -CertificateThumbprint $servicePrincipalConnection.CertificateThumbprint 
    }
    catch {
        if (!$servicePrincipalConnection)
        {
            $ErrorMessage = "Connection $connectionName not found."
            throw $ErrorMessage
        } else{
            Write-Error -Message $_.Exception
            throw $_.Exception
        }
    }

    #Get all ARM resources from all resource groups
    $ResourceGroups = Get-AzureRmResourceGroup 

    foreach ($ResourceGroup in $ResourceGroups)
    {    
        Write-Output ("Showing resources in resource group " + $ResourceGroup.ResourceGroupName)

        if( $ResourceGroup.ResourceGroupName -eq $myResourceGroupName ){
            $Resources = Find-AzureRmResource -ResourceGroupNameContains $ResourceGroup.ResourceGroupName | Select ResourceName, ResourceType
            ForEach ($Resource in $Resources)
            {

                    Write-Output ($Resource.ResourceName + " of type " +  $Resource.ResourceType)

                    Write-Output ($Resource.ResourceName + " of type " +  $Resource.ResourceType)

                    #Switch-AzureMode AzureServiceManagement
                    # Local powershell connects and works perfect with what I wanted to achieve.
                    # On Automation account, Runbook migration, it threw Azure subcription not set error for Set-AzureWebsite. 
                    # so remove rest of the code and focused on few options to get the default as below
                    # which led me to post the thread.
                    # 
                    # Approach 1
                    Select-AzureSubscription -SubscriptionName $defaultSubscriptionname –Default 
                    Get-AzureSubscription -SubscriptionId 1238XXXXXXXXXXXe5XXXX8 | Select-AzureSubscription

                    # Approach 2
                    $subscriptionId = (Get-AzureRmSubscription | Out-GridView -Title 'Select Azure Subscription:' -PassThru).Id
                    Select-AzureRmSubscription -SubscriptionId $subscriptionId

                    Write-Output ( "==============Subscription ID :===========")
                    Write-Output( $subscriptionId)

                    # Wants to update config / php version parameters.
                    Set-AzureWebsite -Name $Resource.ResourceName -HttpLoggingEnabled 1 -PhpVersion 5.6

                    # Had tried this as well which was suggested by Jason. But appears not working.. 
                    # looks like I have messed it up.                        
                    Get-AzureRmWebApp -ResourceGroupName $myResourceGroupName -Name $Resource.ResourceName
                    Set-AzureRmWebApp -ResourceGroupName $myResourceGroupName -Name $Resource.ResourceName -HttpLoggingEnabled 1 -PhpVersion 5.6
            }
        }
        Write-Output ("Completed!@Line83")
    } 
}
}
$connectionName = "jason"
try
{
    # Get the connection "jason "
    $servicePrincipalConnection=Get-AutomationConnection -Name $connectionName         

    "Logging in to Azure..."
    Add-AzureRmAccount `
       -ServicePrincipal `
       -TenantId $servicePrincipalConnection.TenantId `
       -ApplicationId $servicePrincipalConnection.ApplicationId `
       -CertificateThumbprint $servicePrincipalConnection.CertificateThumbprint 
}
catch {
   if (!$servicePrincipalConnection)
   {
      $ErrorMessage = "Connection $connectionName not found."
      throw $ErrorMessage
  } else{
      Write-Error -Message $_.Exception
      throw $_.Exception
  }
}