Skip to content

Instantly share code, notes, and snippets.

@justinyoo
Last active April 16, 2016 11:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save justinyoo/a2d36c1aa6ae678e9c3e18d03b838828 to your computer and use it in GitHub Desktop.
Save justinyoo/a2d36c1aa6ae678e9c3e18d03b838828 to your computer and use it in GitHub Desktop.
Entity Framework 7 Data Migration through KUDU
# Gets the website details.
$website = Get-AzureWebsite -Name "your-azure-website"
# Sets the KUDU endpoint URL.
$kuduApiBaseUri = "https://$($website.Name).scm.azurewebsites.net/api"
$uri = "$kuduApiBaseUri/command"
# Sets the request header.
$username = $website.PublishingUsername
$password = $website.PublishingPassword
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $username, $password)))
$headers = @{ Authorization = ("Basic {0}" -f $base64AuthInfo) }
# Sets the request body in JSON format.
$body = ConvertTo-Json @{ command = "db-migration.cmd"; dir = "site\approot\src\MyWebAppProject" }
# Sends request to KUDU REST API
$result = Invoke-RestMethod -Uri $uri -Headers $headers -Method Post -Body $body -ContentType "application/json"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment