title: Adding an App Settings to existing Azure Web Application using Azure Power Shell
body: <p>I want to write a script that run using azure power shell to automate adding the Web Application configuration</p>
  
  <p>Azure > MyWebApp > Application Settings > App settings</p>
  
  <p>It's look like key = "value"</p>
  
  <p>I write this script </p>
  
  <pre><code>###########################
  # MyApp Config Automation #
  ###########################
  
  #Begin
  
  $subscriptionName="MySubscriptionName"
  $webSiteName="MyWebAppName"
  $storageAccountName="StorageAccountName"
  ########################################
  $userName = "myaccount@outlook.com"
  $securePassword = ConvertTo-SecureString -String "mypass" -AsPlainText -Force
  #####################################
  $cred = New-Object System.Management.Automation.PSCredential($userName, $securePassword)
  #####################################
  Add-AzureAccount -Credential $cred 
  Select-AzureSubscription -SubscriptionName $subscriptionName -Default
  #####################################
  Get-AzureWebsite -Name $webSiteName
  
  #End
  </code></pre>
  
  <p>but i know that the above script is only get my web application, now i need to access  MyWebApp > Application Settings > App settings and give the script file/array of my new App settings and the script check if there are any new App Settings key it will add it to App Settings, if there are any existing keys it will override it's value.
  What is the steps or APIS or can i do that with azure power shell?</p>
  
  <p>Edit:
  This script can Automate creating new web application and adding App Settings to it:</p>
  
  <pre><code>##############################################
  # Creating website and Adding Configs Script #
  ##############################################
  
  $webSiteName="mywebsite"
  $storageAccountName="storageaccount"
  $subscriptionName="mysubsc"
  $userName = "myaccount"
  $securePassword = ConvertTo-SecureString -String "mypass" -AsPlainText -Force
  $cred = New-Object System.Management.Automation.PSCredential($userName, $securePassword)
  Add-AzureAccount -Credential $cred 
  Select-AzureSubscription -SubscriptionName $subscriptionName -Default
  
  New-AzureWebsite -Name $webSiteName
  New-AzureStorageAccount –StorageAccountName $storageAccountName -Location "South Central US"
  $ClientId="dfgdf6"
  $Password="ffefe"
  $StorageAccountKey = Get-AzureStorageKey -StorageAccountName $storageAccountName
  $AppSettings = @{"StorageAccountPrimary" = $StorageAccountKey.Primary;"StorageAccountSecondary" = $StorageAccountKey.Secondary;"ida:ClientId"=$ClientId;"ida:Password"=$Password}
  
  Set-AzureWebsite -Name $webSiteName -AppSettings $AppSettings
  </code></pre>