MS Azure Emulator through IIS - visual-studio

I am facing issue of starting MS Azure Emulator every time I run the application. May be the process I am following is not correct. It is like:
1) Edit code
2) run the project by hitting F5 in Visual Studio (Azure project is startup project)
3) VS starts Ms Azure Emulator
4) finally application runs in local host (in VS inbuilt web server) having some url like 127.0.0.1:82
The overhead is that each time i am making a change, i am doing the above 4 steps. That kills considerable amount of development time.
My question: Is there any way to directly run using IIS like
1) Edit code
2) Build and start the application in browser
3) attach to the process w3wp for debugging.
I am a new in azure kinda project. Your help will be appreciated.
My ServiceDefinition.csdef:
<?xml version="1.0" encoding="utf-8"?>
<ServiceDefinition name="ABC" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition">
<WebRole name="ABCWebRole">
<Sites>
<!--<Site name="External" physicalDirectory="..\External">
<Bindings>
<Binding name="Http" endpointName="HttpIn" />
</Bindings>
</Site>-->
<Site name="ABCWebRole" physicalDirectory="..\ABCWebRole">
<Bindings>
<Binding name="Http" endpointName="HttpIn" />
<!--<Binding name="HttpsIn" endpointName="HttpsIn" hostHeader="app.ABC.com" />-->
</Bindings>
</Site>
</Sites>
<ConfigurationSettings>
<Setting name="StorageConnectionString" />
<Setting name="SmtpServer" />
<Setting name="SmtpPort" />
<Setting name="SmtpUsername" />
<Setting name="SmtpPassword" />
<Setting name="myDSUserName" />
<Setting name="myDSPassword" />
<Setting name="myDSIntegratorKey" />
<Setting name="APIUrl" />
<Setting name="AccountManagementUrl" />
<Setting name="myDSEmail" />
<Setting name="myDSAccountId" />
<Setting name="DSmemberPassword" />
<Setting name="QueueNamespace" />
<Setting name="QueueIssuer" />
<Setting name="QueueIssuerKey" />
<Setting name="ShowingFeedbackQueueName" />
<Setting name="ServiceReportQueueName" />
</ConfigurationSettings>
<LocalResources>
<LocalStorage name="ABCLocal" cleanOnRoleRecycle="true" sizeInMB="1024" />
<LocalStorage name="DiagnosticStore" cleanOnRoleRecycle="true" sizeInMB="7000" />
<LocalStorage name="CustomLogging" cleanOnRoleRecycle="true" sizeInMB="1024" />
</LocalResources>
<Certificates>
<Certificate name="app.ABC.com" storeLocation="LocalMachine" storeName="My" />
</Certificates>
<Endpoints>
<InputEndpoint name="HttpsIn" protocol="https" port="443" certificate="app.ABC.com" />
<InputEndpoint name="HttpIn" protocol="http" port="80" />
</Endpoints>
<Imports>
<Import moduleName="Diagnostics" />
</Imports>
</WebRole>
<WorkerRole name="ABCWorkerRole" vmsize="ExtraSmall">
<!--Remove diagnostics permissions fix... Remember to remove the associated files<Startup>
<Task commandLine="FixDiag.cmd" executionContext="elevated" taskType="background" />
</Startup>
-->
<Imports>
<Import moduleName="Diagnostics" />
</Imports>
<ConfigurationSettings>
<Setting name="StorageConnectionString" />
<Setting name="SmtpServer" />
<Setting name="SmtpPort" />
<Setting name="SmtpUsername" />
<Setting name="SmtpPassword" />
<Setting name="QueueNamespace" />
<Setting name="QueueIssuer" />
<Setting name="QueueIssuerKey" />
<Setting name="ShowingFeedbackQueueName" />
<Setting name="ServiceReportQueueName" />
</ConfigurationSettings>
<LocalResources>
<LocalStorage name="DiagnosticStore" cleanOnRoleRecycle="true" sizeInMB="7000" />
<LocalStorage name="CustomLogging" cleanOnRoleRecycle="true" sizeInMB="1024" />
</LocalResources>
</WorkerRole>
</ServiceDefinition>

I typically configure my service to be able to run in Azure or in IIS . It takes a little time to set it up at the beginning then later it's a matter of which project you choose to run from visual studio, so when you set the .ccproj as startup project, it runs in azure when you hit F5. Otherwise, when you set the .csproj as startup project, you can then run it in cassini, IIS Express or Local IIS based on how you configure your web app. The one time change that you need to make is move the logic that hooks to the Azure Diagnostics listener from the web.config to Global.asax->Application_Start() or WebRole.cs->Onstart() methods where you can check if the service is running inside or outside Azure environment through the RoleEnvironment object and the code would like this
if (RoleEnvironment.IsAvailable)
{
Trace.Listeners.Add(new DiagnosticMonitorTraceListener
{
Name = "AzureDiagnostics",
Filter = new EventTypeFilter(SourceLevels.All)
});
}
else
{
...hook it to a listener that writes logs to an xml file or something
}
Keep in mind that when running outside the azure environment, you're going to lose Azure specific functionalities, like ability to read .cscfg values through the RoleEnvironment object (but web.config will still be accessible from both). And you have to also run the worker role manually through a different type of configuration (less straight forward)

Related

User-specific IIS config

Under MyProject > Properties > Web there is an option to "Apply server settings to all users" which stores the IIS config in MyProject.csproj.user.
However, there doesn't seem to be a way to set defaults. Meaning anyone who clones the project will have to customize these settings.
Is there a way to set defaults when using user-specific IIS settings?
I've attempted to use environment variables, but Visual Studio complains that it cannot create an IIS binding for http://$(API_HOST):$(API_PORT)/
What is the setting you need to set? This is an important detail.
Most of the configuration could be setted in the web.config file infact this file has a "system.webServer" section dedicated to IIS Configuration.
example:
<system.webServer>
<defaultDocument enabled="true">
<files>
<add value="Default.htm" />
<add value="Index.htm" />
<add value="Index.html" />
</files>
</defaultDocument>
<directoryBrowse enabled="true" />
<httpErrors>
<error statusCode="404" prefixLanguageFilePath="%SystemDrive%\inetpub\custerr" path="my_custom_404.htm" />
</httpErrors>
<security>
<authentication>
<anonymousAuthentication enabled="true" userName="IUSR" />
<basicAuthentication />
<clientCertificateMappingAuthentication />
<digestAuthentication />
<iisClientCertificateMappingAuthentication />
<windowsAuthentication />
</authentication>
<requestFiltering>
<fileExtensions allowUnlisted="true" applyToWebDAV="true" />
<verbs allowUnlisted="true" applyToWebDAV="true" />
<hiddenSegments applyToWebDAV="true">
<add segment="Web.config" />
</hiddenSegments>
</requestFiltering>
</security>
<staticContent lockAttributes="isDocFooterFileName">
<mimeMap fileExtension=".mp3" mimeType="otect/stream" />
</staticContent>
</system.webServer>
source:
https://learn.microsoft.com/en-us/iis/configuration/system.webserver/

How to troubleshoot local Windows UWP (Cordova) networking issues

I have a Windows 10 UWP application built using Ionic/Cordova, so my http requests originate from the embedded webview.
I can run my application at home, or on a tablet connected via cell and the http requests all work. However, when I run this on any office machine (work machines), the requests other than to local host appear to be blocked. I initially thought this was the network, however using Wireshark, I can see the request if I just run them in the machine browser, but I can't see them if I run the same from the application.
If I run the application via the desktop browser (using Ionic serve), it also works. It only seems to be when it is running in the UWP container.
Since the requests don't appear in Wireshark, I have no idea how to diagnose where this is getting blocked.
How can I diagnose this (I assume the local TCP/IP stack?)
Update 1
Some more information on a minimal application
I create a new Ionic 3 application, straight from a template, and my config.xml looks something like
<?xml version='1.0' encoding='utf-8'?>
<widget id="io.ionic.starter" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>MyApp</name>
<description>An awesome Ionic/Cordova app.</description>
<author email="hi#ionicframework" href="http://ionicframework.com/">Ionic Framework Team</author>
<content src="index.html" />
<access origin="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<allow-navigation href="*" />
<feature name="http://api.phonegap.com/1.0/network" />
<access origin="*" />
<preference name="webviewbounce" value="false" />
<preference name="UIWebViewBounce" value="false" />
<preference name="DisallowOverscroll" value="true" />
<preference name="android-minSdkVersion" value="16" />
<preference name="BackupWebStorage" value="none" />
<preference name="SplashMaintainAspectRatio" value="true" />
<preference name="FadeSplashScreenDuration" value="300" />
<preference name="SplashShowOnlyFirstTime" value="false" />
<preference name="SplashScreen" value="screen" />
<preference name="SplashScreenDelay" value="3000" />
<preference name="windows-target-version" value="10.0" />
<platform name="android">
...
<platform name="ios">
...
</platform>
<engine name="windows" spec="^5.0.0" />
<plugin name="cordova-plugin-console" spec="^1.0.5" />
<plugin name="cordova-plugin-device" spec="^1.1.4" />
<plugin name="cordova-plugin-splashscreen" spec="^4.0.3" />
<plugin name="cordova-plugin-statusbar" spec="^2.2.2" />
<plugin name="cordova-plugin-whitelist" spec="^1.3.1" />
<plugin name="ionic-plugin-keyboard" spec="^2.2.1" />
<plugin name="cordova-plugin-wkwebview-engine" spec="^1.1.3" />
</widget>
When I build to the Window package, the AppxManifest.xml includes the following...
<Capabilities>
<Capability Name="internetClient" />
</Capabilities>
The test service should by CORS enabled, and I can connect to it via cell, and any other network I have tried except for our office network, as we have no idea where it is being blocked. I don't see anything in wireshark. If I run the same application via Ionic serve (so running in the desktop browser), then I have no problems. If I install the Windows version at home, I can connect. If I install it on a Tablet (eg Surface), then is does NOT connect if the serface is on the office WIFI, but it DOES connect if I tether the surface to my phone.
If we give the Surface a fixed IP it also then seems to work. I have no idea why the fixed IP makes a difference.
The actual test app code looks like the following (the only difference is the url to the office test server)...
export class HomePage {
public result : any;
public url : string;
constructor(public navCtrl: NavController, private http: Http) {
this.url='http://mytesturl';
}
public onClick() : void {
this.http.get(this.url).subscribe(res => {
this.result = res.statusText;
console.log(res);
}, (error : Response) => {
let json = error.json();
this.result = `failed ${error.statusText}`;
console.log(error);
});
}
}
We had the same problem and fixed it by adding the capability "privateNetworkClientServer" to the app. Perhaps that's your problem as well?

Where is the package sources location

I use VS 2015 .Where in the visual studio project store the setting of Tools>options >Nuget Package Manager >Package Sources's setting. Currently Nuget.org is checked for Package Sources.I want to point this to a different location other than https://www.nuget.org/api/v2/, by editing the file location.
I checked the project file csproj, but did not find it
I need to change this manually in the server to point to the server repository. Working fine in local machine but not in the server.
This is a per-user setting, and is stored in %APPDATA%\NuGet\NuGet.Config. The file looks like:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
<add key="Abc" value="http://def/nuget/" />
<add key="Package source" value="http://packagesource" />
</packageSources>
<packageRestore>
<add key="enabled" value="True" />
<add key="automatic" value="True" />
</packageRestore>
<bindingRedirects>
<add key="skip" value="False" />
</bindingRedirects>
</configuration>
Simply add another entry into the <packageSources> element. (Mine is obviously updated for the protocol version 3 and so is referencing https://api.nuget.org/v3/index.json rather than https://www.nuget.org/api/v2/).

Can I use ant war task to export a war built with Maven?

Im using eclipse and maven for my day to day development, which works fine. However I need a specialized war created when its time to export to send over to production, which includes things like minifying and combining js/css etc, separating out static resources for apache rather than tomcat etc.
I tried the maven plugin route but it was a hassle, I'd rather write a simply ant script to export when necessary. I'm using the ant war task, but the exported war contains everything except my WEB-INF/libs folder, which is blank. Does anyone know a way to make the script work with all the libs that maven looks up? This is what I have:
<?xml version="1.0" encoding="UTF-8"?>
<project name="MyProject" default="war" basedir=".">
<property name="builder" value="Me" />
<property name="project-name" value="${ant.project.name}" />
<property name="war-file-name" value="${project-name}.war" />
<property name="source-directory" value="src/main/java" />
<property name="classes-directory" value="target/classes" />
<property name="web-directory" value="src/main/webapp" />
<property name="web-xml-file" value="src/main/webapp/WEB-INF/web.xml" />
<property name="build-directory" value="/" />
<tstamp prefix="build-info">
<format property="current-date" pattern="d-MMMM-yyyy" locale="en" />
<format property="current-time" pattern="hh:mm:ss a z" locale="en" />
</tstamp>
<target name="war" depends="">
<mkdir dir="${build-directory}" />
<delete file="${build-directory}/${war-file-name}" />
<war warfile="${build-directory}/${war-file-name}" webxml="${web-xml-file}">
<classes dir="${classes-directory}" />
<fileset dir="${web-directory}">
<exclude name="WEB-INF/web.xml" />
</fileset>
<manifest>
<attribute name="Built-By" value="${builder}" />
<attribute name="Built-On" value="${build-info.current-date}" />
<attribute name="Built-At" value="${build-info.current-time}" />
</manifest>
</war>
</target>
</project>
You can use maven ant tasks for this. I have not tried this, but from the examples, something like this should work...
<artifact:dependencies filesetId="dependency.fileset" useScope="runtime">
<pom file="pom.xml"/>
</artifact:dependencies>
<copy todir="${webapp.output}/WEB-INF/lib">
<fileset refid="dependency.fileset" />
<!-- This mapper strips off all leading directory information -->
<mapper type="flatten" />
</copy>

Why does my Azure deployment still have a 3rd endpoint for Remote Desktop even though I've disabled it?

I previously enabled remote desktop in my Azure project to allow me to debug in our staging environment. This added a 3rd endpoint on port 3389 in addition to 80 and 443.
I've finished debugging and disabled remote desktop in the publishing wizard then did another deployment to staging. I then tried to do a VIP swap with our production instance, but Azure admin console is throwing an error due to staging have 3 endpoints and production have 2 (you can't do a VIP swap between instances that have different # of endpoints).
Here's what I've done to verify remote desktop is disabled:
I've triple checked that in the publish wizard that I specific to have remote desktop disabled.
The .azurePubxml has:
<AzureEnableRemoteDesktop>False</AzureEnableRemoteDesktop>
The cscfg has:
<Setting name="Microsoft.WindowsAzure.Plugins.RemoteAccess.Enabled" value="false" />
4.My csdef has:
<?xml version="1.0" encoding="utf-8"?>
<ServiceDefinition name="mysite.App" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition">
<WebRole name="www" vmsize="Small">
<Sites>
<Site name="Web">
<VirtualApplication name="r" physicalDirectory="../ReviewPost/ReviewPost" />
<Bindings>
<Binding name="Endpoint1" endpointName="Endpoint1" />
<Binding name="Endpoint2" endpointName="Endpoint2" />
</Bindings>
</Site>
</Sites>
<Endpoints>
<InputEndpoint name="Endpoint1" protocol="http" port="80" />
<InputEndpoint name="Endpoint2" protocol="https" port="443" certificate="STAR.mysite.com" />
</Endpoints>
<Imports>
<Import moduleName="Diagnostics" />
<Import moduleName="RemoteAccess" />
<Import moduleName="RemoteForwarder" />
</Imports>
<Certificates>
<Certificate name="STAR.mysite.com" storeLocation="LocalMachine" storeName="My" />
</Certificates>
</WebRole>
</ServiceDefinition>
Despite the above configuration, the azure console is showing 3 endpoints (port 80, 443 and 3389) for the staging environment.
What am I missing?
Based on information from #smarx in the MSDN forums mirror of my question here's the solution:
Remove these lines from your .csdef:
<Import moduleName="RemoteAccess" />
<Import moduleName="RemoteForwarder" />
These 2 lines control the creation of the extra endpoint even though remote access may be disabled.

Resources