Publishing ASP.Net Core app to Azure silently fails in command line - asp.net

I'm trying to publish a dotnet core app to Azure. I've created a publish profile and using visual studio it all works fine. But since I'd like to setup continuous deployment I need to run the deployment using command line.
The official documentation was pretty helpful in identifying that the [ProfileName].ps1 is the best plan of attack.
However it gives no clues on how to use it.
First I ran it without parameters and got this error:
Production-publish.ps1 : The term 'Production-publish.ps1' is not recognized as the name of a cmdlet, function, script
file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct
and try again.
At line:1 char:1
+ Production-publish.ps1
+ ~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Production-publish.ps1:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Next I added the needed parameters:
.\Production-publish -packOutput 'C:\code\my-dotnetcore-proj\publish' -pubProfilePath 'Production.pubxml'
Which ran without error but didn't do ANYTHING!
How can I make the Azure depoyment via Powershell work?

After debugging through the publish-module.psm1 to figure out why nothing was getting deployed I noticed that the command is required to supply more parameters. This is how:
.\Production-publish -packOutput 'C:\code\my-dotnetcore-proj\publish' -pubProfilePath 'Production.pubxml' -publishProperties #{
'username' = '%PublishProfile.Username%'
'Password' = '%PublishProfile.Password%'
'AllowUntrustedCertificate' = false
'AuthType' = 'Basic'}
You obviously have to replace %PublishProfile.Username% and %PublishProfile.Password% and possibly modify Production-publish and Production.pubxml
Note that only the Password parameter is required (considering that the UserName is provided in your .pubxml file)
I actually ended up writing blog article on how to compile and deploy asp.net core sites with TeamCity:
How to deploy ASP.NET Core sites using Teamcity to Azure/IIS … or just command line

Related

Why is gmailr not working in docker build process?

I'm using the gmailr package for sending emails from a r script.
Locally it's all working fine, but when I try to run this during a docker build step in google cloud I'm getting an error.
I implemented it in the following way described here.
So basically, locally the part of my code for sending emails looks like this:
gm_auth_configure(path = "credentials.json")
gm_auth(email = TRUE, cache = "secret")
gm_send_message(buy_email)
Please note, that I renamed the .secret folder to secret, because I want to deploy my script with docker in gcloud and didn't want to get any unexpected errors due to the dot in the folder name.
This is the code, which I'm now trying to run in the cloud:
setwd("/home/rstudio/")
gm_auth_configure(path = "credentials.json")
options(
gargle_oauth_cache = "secret",
gargle_oauth_email = "email.which.was.used.to.get.secret#gmail.com"
)
gm_auth(email = "email.which.was.used.to.get.secret#gmail.com")
When running this code in a docker build process, I'm receiving the following error:
Error in gmailr_POST(c("messages", "send"), user_id, class = "gmail_message", :
Gmail API error: 403
Request had insufficient authentication scopes.
Calls: gm_send_message -> gmailr_POST -> gmailr_query
I can reproduce the error locally, when I do not check the
following box.
Therefore my first assumption is, that the secret folder is not beeing pushed correctly in the docker build process and that the authentication tries to authenticate again, but in a non interactive-session the box can't be checked and the error is thrown.
This is the part of the Dockerfile.txt, where I'm pushing the files and running the script:
#2 ADD FILES TO LOCAL
COPY . /home/rstudio/
WORKDIR /home/rstudio
#3 RUN R SCRIPT
CMD Rscript /home/rstudio/run_script.R
and this is the folder, which contains all files / folders beeing pushed to the cloud.
My second assumption is, that I have to somehow specify the scope to use google platform for my docker image, but unfortunately I'm no sure where to do that.
I'd really appreciate any help! Thanks in advance!
For anyone experiencing the same problem, I was finally able to find a solution.
The problem is that GCE auth is set by the "gargle" package, instead of using the "normal user OAuth flow".
To temporarily disable GCE auth, I'm using the following piece of code now:
library(gargle)
cred_funs_clear()
cred_funs_add(credentials_user_oauth2 = credentials_user_oauth2)
gm_auth_configure(path = "credentials.json")
options(
gargle_oauth_cache = "secret",
gargle_oauth_email = "sp500tr.cloud#gmail.com"
)
gm_auth(email = "email.which.was.used.for.credentials.com")
cred_funs_set_default()
For further references see also here.

How to use the password in pubxml.user during dotnet publish

I am trying to setup CI for a ASP.NET project. There is a publish profile defined in VS, which is working fine. (I can deploy the page to a remote IIS server.)
I want to automate this, using GitLab, so I am looking for a command line equivalent of the publish action of VS.
The publish profile files that VS is using can be found under Properties\PublishProfiles. I have 2 files here:
myServer.pubxml (contains the username to use for deploy, and other server data, like hostname)
myServer.pubxml.user (contains the encrypted password for the user)
My attempts to deploy/publish on the command line:
dotnet publish /p:PublishProfile=myServer.pubxml
This results in the following error:
MSDEPLOY : error Code: ERROR_USER_UNAUTHORIZED [C:\Users\myUser\source\repos\Beam Time Request\BeantimeRequest\BeantimeRequest.csproj] Error : The remote server returned an error : (401) Unauthorized. [C:\Users\myUser\source\repos\Beam Time Request\BeantimeRequest\BeantimeRequest.csproj] MSDEPLOY : error count: 1. [C:\Users\myUser\source\repos\Beam Time Request\BeantimeRequest\BeantimeRequest.csproj]
Which is logical, as I have not defined the password.
I can set the password on the command line, like this:
dotnet publish /p:PublishProfile=myServer.pubxml /p:password=myPassword
And this works, but I want to avoid having the password written in plain text.
So how could I tell dotnet publish to use the password from the myServer.pubxml.user file?
If anyone come across this:
I solved this with a GitLab Secret, as follows:
Defined a new GitLab Secret for the repository, called DEPLOY_PASSWD
using the following command to deploy:
dotnet publish -c Release -o Publish /p:PublishProfile=myServer.pubxml /p:password=$DEPLOY_PASSWD"

How do I fix the "pip not recognized error" in VS code

So I am new to learning python and I am following a project guide in VS code. It has me type in the terminal "pip get requests bs4" to continue with the guide. But whenever I type it in, I get this error:
"*pip : The term 'pip' is not recognized as the name of a cmdlet, function, script file, or
operable program. Check the spelling of the name, or if a path was included, verify that the
path is correct and try again.
At line:1 char:1
pip get requests bs4
+ CategoryInfo : ObjectNotFound: (pip:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException*"
I have literally tried everything, researched everywhere and nothing. I tried repairing python, I tried adding the "path" to my environment variables. Nothing worked. Looking for some help as this is kind of putting a halt on my python learning.

Firebase not instal on windows 10

fierbase: The name "fierbase" is not recognized as the name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, as well as the presence and correctness of the path, and then try again.
line: 1 character: 1
fierbase login
+ CategoryInfo: ObjectNotFound: (fierbase: String) [], CommandNotFoundException
+ FullyQualifiedErrorId: CommandNotFoundException
PS.
Did everything written in thi instructions on the official website, but still can not install write that I didnt have firebase on my conputer,Nodejs and NPM the latest versions, and I have NPM in my PATH.
As the error you are receiving clearly states, you should verify the spelling of the command you are trying to run. You are misspelling firebase as fierbase.

MSdeploy in Powershell - show or help me something really working

I set up TFS Deployer currenlty at work and have been tried to write a Powershell script for the deployment. I have been researched and read many posted questions and answers at StackoverFlow but I couldn't really making the script working yet.
So far, when I run the following PS on windows PowerShell ISE, it runs.
$envMsDeploy = $env:msdeploy
$DirMsDeploy = split-Path -Parent $envMsDeploy
# defined the current location to $DirMSDeploy = C:\Program Files\IIS\Microsoft Web Deploy V2
set-location $DirMsDeploy
$arg = #(
'-verb:sync';
'-source:contentPath=' + $buildDroppedLocation;
'-dest:contentPath=' + $destinationPath;
' -whatif > c:\temp\msdeploy.log'
)
$runMSDeploy = ($DirMsDeploy + "\Msdeploy.exe " + $arg)
$runMSDeploy | Out-file c:\temp\MsDeployTest.bat
I put the last sentence to confirm what gets saved $runMSDeploy. Now looks like $runMSDeploy saves what I want to put finally.
MSDeployTest.Bat contains C:\Program Files\IIS\Microsoft Web Deploy V2\Msdeploy.exe -verb:sync -source:contentPath=[[c:\source folder]] -dest:contentPath=[[Detination UNC path]] -whatif > c:\temp\msdeploy.log
This is where I'm stuck at right now. Because of the c:\Program files contains the empty folder, cmd doesn't run successfully rather giving me the error, "cmd.exe : 'C:\Program' is not recognized as an internal or external command"
If you have any suggestions or idea, please let me know.
thanks,
wanttogoshreddingeveryday
Here is a small example which start notepad.exe with a parametter
function F([string]$file)
{
notepad.exe $file
}
Clear-Host
F "c:\Temp\fic.txt"
JP
Try this gist. It should have everything you need to deploy via powershell https://gist.github.com/579086
It uses Psake, but it will work without it as well.

Resources