Previously uploading publish files to azure web apps using FileZilla .but i am trying 2 or more files uploading to azure web apps using powershell scripts now.please help me any power shell script .
but i am trying 2 or more files uploading to azure web apps using powershell scripts now.please help me any power shell script.
I assumed that you could use powershell script for deploying your web app code using FTP (via WebClient.UploadFile()) and recursively upload your publish files as follows:
# Upload files recursively
Set-Location $appdirectory
$webclient = New-Object -TypeName System.Net.WebClient
$webclient.Credentials = New-Object System.Net.NetworkCredential($username,$password)
$files = Get-ChildItem -Path $appdirectory -Recurse | Where-Object{!($_.PSIsContainer)}
foreach ($file in $files)
{
$relativepath = (Resolve-Path -Path $file.FullName -Relative).Replace(".\", "").Replace('\', '/')
$uri = New-Object System.Uri("$url/$relativepath")
"Uploading to " + $uri.AbsoluteUri
$webclient.UploadFile($uri, $file.FullName)
}
$webclient.Dispose()
For more details, you could refer to Upload files to a web app using FTP.
Additionally, you could Using KUDU with Microsoft Azure Web Apps, click "Debug Console > PowerShell or CMD" to open a console, then cd site\wwwroot to the web content of your web app, then you could drag your publish files, and drop them directly into the Kudu console's file explorer UI for uploading files. For more details, you could refer to Kudu console about uploading files.
Related
I manually do these now. Is there a way to automate the above steps via PowerShell script?
You need site owner permissions to be able to add apps to SharePoint Online Site.
Refer to my PnP Powershell script:
#Parameters
$SiteURL = "https://crescent.sharepoint.com/sites/Legal"
$AppName = "Modern Script Editor web part by Puzzlepart"
#Connect to SharePoint Online App Catalog site
Connect-PnPOnline -Url $SiteURL -UseWebLogin
#Get the App from App Catalog
$App = Get-PnPApp -Scope Tenant | Where {$_.Title -eq $AppName}
#Install App to the Site
Install-PnPApp -Identity $App.Id
I'm trying to take specific configuration backup in Azure webapp wwwroot folder with below powershell script which was working fine in public App service plan(Standard and Premium) but the same powershell script is not working fine in Private App service plan(Isolated(App service Environment) - I1,I2,I3). Please find the code below.
Code:
Import-Module Kudu-api
$userNm="`$Testapp"
$password="*******"
$token = New-KuduAuthorizationToken $userNm $password
$sitename="Testapp"
Set-Location "C:\Users\admin\Desktop\Backups"
sleep -Seconds 2
Receive-KuduFile $sitename $token '/site/wwwroot/appsettings.json' ./appsettings.json`
Getting the below error when trying the above script in Isolated(I1) appservice plan:
Error : Invoke-RestMethod : The remote name could not be resolved: 'Testapp.scm.azurewebsites.net'
Please suggest how we can resolve this.
Trying to execute ps script on azure vm's using azure automation using the approach defined at
https://stackoverflow.com/a/62258063/1014275. Script below does copy files between azure vm's. Both Vm's are in same subnet and if we run the copy-item command from VM powershell it copies the files to target VM folder. The same script executes successfully with azure automation runbooks, but without copying files.
Script used:
Copy-Item -Path C:\folder\sample.txt -Destination \\\VmHostname\C$\folder -Force
Updated 1: The script throws exception as below.
Failed
VERBOSE: Performing the operation "Copy File" on target "Item: C:\folder\file.txt Destination:
\\vmhostname\C$\folder". Copy-Item : You can't connect to the file share because it's not secure. This share requires the obsolete SMB1
protocol, which is unsafe and could expose your system to attack.
Your system requires SMB2 or higher.
Update 2:
run the below ps command (Solved update 1 issue)
Enable-WindowsOptionalFeature -Online -FeatureName SMB1Protocol
after this we are getting below error
Failed
Copy-Item : Access is denied
At C:\Packages\Plugins\Microsoft.CPlat.Core.RunCommandWindows\1.1.5\Downloads\script17.ps1:1 char:1
+ Copy-Item -Path C:\folder\file.txt -Destination \\vmhostname ...
Any suggestion would be helpful!
We are getting error Error during upload when uploading a file that is configured to save files to SharePoint Online. This is on Microsoft Dynamics AX 2012 R3.
We have document management enabled, we are currently saving files to a local folder on the AOS server but now want to save files to our online sharepoint library in O365.
I created the following folder AXTest in sharepoint, and granted the AX service account access to the sharepoint team.
I set Archive directory appropriately. I tried various veresions of the URL, which were all unsuccessful:
https://xxxxx.sharepoint.com/sites/Dev-Test/AXTest
https://xxxxx.sharepoint.com/sites/Dev-Test/AXTest/Forms
various document folders
All result in error when trying to upload a file that is local to the AOS server:
Through debugging, the error is raised here.
There is no exception stack so I don't know the exact reason why, but we tried various versions of the URL, we tried uploading a file locally, and we know the service account has access to the sharepoint site/team. Any other ideas?
Late but the "solution" is to make sure that a persistent cookie for SharePoint Online exists locally. I have been biting my head off to find a better solution, because it can get pretty complex to get that persistent cookie which makes it not suitable for end-users. To the point that my only solution might be to build a custom connector (or to urge for an upgrade...)
The key is to somehow force login.microsoftonline.com to prompt the user the question to remain signed-in. Only when you click Yes in that dialog is a persistent cookie created for SPO. Then the upload works fine, until the cookie expires / gets deleted.
These are the instructions for our users:
1. Make sure SPO / MS / Azure / ADFS related urls are not in the intranet zone in IE to prevent automatic login with windows credentials.
2. Sign out of SPO
3. Delete browser cookies
3. Restart IE
4. Go to SPO
5. You should be prompted to login with username and password
6. Then you will receive the question to Remain signed in. Click Yes.
Optional if this didnt work: Reset IE to default settings.
There's a KB included in CU13 for AX2012 R3 that seems to address the issue (mentions the vague "Error during upload" error). Haven't tested it myself, because i am trying to solve it in an AX2012 R2 CU9 environment.
I just ran across the same issue and what a NIGHTMARE!
For Windows Server 2012 R2, I wrote this little PowerShell script to help clear the cookies for all users.
We had users sign out of AX, sign off the terminal server(s), and then I ran the below script to just remove all user cookies. Next connection, they were in business.
$Remove = $false
Get-ChildItem -Path "C:\Users" -Directory | % {
$CachePath = Join-Path -Path $_.FullName -ChildPath "\AppData\Local\Microsoft\Windows\INetCache"
$CookiePath = Join-Path -Path $_.FullName -ChildPath "\AppData\Local\Microsoft\Windows\INetCookies"
if (Test-Path -Path $CookiePath)
{
Write-Host $_.FullName -ForegroundColor Green
if ($Remove) {
Get-ChildItem -Path $CookiePath -File -Recurse | Remove-Item -Force -ErrorAction Continue
Get-ChildItem -Path $CachePath -File -Recurse | Remove-Item -Force -ErrorAction Continue
} else {
Get-ChildItem -Path $CookiePath -File -Recurse | Format-Table -AutoSize
Get-ChildItem -Path $CachePath -File -Recurse | Format-Table -AutoSize
}
}
}
Code That I am running on azure portal
Write-Output "Starting"
$assemblyPath = "C:\Modules\Global\Azure\Compute\Microsoft.Exchange.WebServices.dll"
dir $assemblyPath
Write-Output "1"
Add-Type -Path $assemblyPath
Write-Output "2"
Output
Any idea on this?
To load the .dll assembly, you could refer to the steps.
1.Navigate to your automation account in the portal-> Modules -> Add Module, compress the Microsoft.ApplicationInsights.dll file to Microsoft.ApplicationInsights.zip, then upload. After uploading, you will find it in the portal.
2.Change the $assemblyPath, your complete command should be as below, it will work fine.
Write-Output "Starting"
$assemblyPath = "C:\Modules\User\Microsoft.ApplicationInsights\Microsoft.ApplicationInsights.dll"
dir $assemblyPath
Write-Output "1"
Add-Type -Path $assemblyPath
Write-Output "2"
Output: