Is it possible to use Managed Identity authentication with .NET Framework web jobs? - azure-webjobs

My team recently upgraded our .netcore components to use Managed Identities to authenticate with Azure Service Bus.
services.AddAzureClients(builder =>
{
var credential = new DefaultAzureCredential(new DefaultAzureCredentialOptions
{
ManagedIdentityClientId = clientId
});
});
We've been asked to upgrade our legacy .NET Framework 4.7.2 web jobs (SDK 2.0) to also use Managed Identities.
Does anyone know if it is possible to use Managed Identities with .NET Framework web jobs and their JobHot(JobHostingConfiguration) start up code?, or would we need to migrate our components to .netcore?
We have a road map to upgrade our .NET Framework components in the future, but I'm wondering if we need to fast track the upgrade if we want to use Managed Identities.
Any advice would be much appreciated.

I think I figured it out. I needed to install/upgrade the following packages to use the WebJobs SDK 3.0.
Microsoft.Azure.WebJobs(>= 3.0.10)
Microsoft.Azure.WebJobs.Extensions
Microsoft.Azure.WebJobs.Extensions.ServiceBus
Microsoft.Azure.WebJobs.ServiceBus
This should allow me to auto-bind the ServiceBusTrigger using the Connection property.
public static void ProcessMessage(
[ServiceBusTrigger("test", Connection = "ServiceBusConnection")]string myQueueItem,
ILogger log)
{
log.LogInformation(myQueueItem);
}

Related

Testing gmail addon

I've created a gmail addon which uses oauth to make external api calls using UrlFetchApp and then uses cards with CardService to show some info.
It all works but there's no documentation on the gmail addon page about how to test the addon. My goal is to write some unit and integration test for my addon core working and have it run on ci services such as Travis. There are many classes the addon uses which are only available in the app script environment such as CardService, OAuth2, GmailApp so mocking all of their functions is quite a bit of work.
Has anybody developed gmail addon with tests which can run on ci services?
GMail add-ons are relatively new to the GSuite ecosystem so you're unlikely to find mocks for it. However, there have been attempts to build Test frameworks for Apps Script.
There is an "awesome list" of GAS resources maintained by Alexander Ivanov on Github with a section dedicated to testing. See link below:
https://github.com/oshliaer/google-apps-script-awesome-list#testing
In its current state it may be difficult to set up Apps Script for continuous integration but with the planned language upgrade to Chrome's V8 engine that may soon change.

How to consume credential based webservice (asmx) in Asp.net Core web application?

I am facing issue while adding asmx service in .NetCore Console application. I am using WCF Connected Service extension as add web reference is not available. So,I followed the same steps which was suggested in following link
https://blogs.msdn.microsoft.com/webdev/2016/06/26/wcf-connected-service-for-net-core-1-0-0-and-asp-net-core-1-0-0-is-now-available/
After completing all step it provided auto-generated reference class which contains all method as async method. My asmx service required username and password authentication for each method and we pass credential as first parameter of any method.
for example, using web reference my method looks like GetData(Credential credential) but here auto generated class shows this method like
GetDataAsync() so I used the below mention code to pass the credentials before calling my web service method
client.ClientCredentials.UserName.UserName = "myusername";
client.ClientCredentials.UserName.Password = "mypassword";
It's giving me Not Authorized error, after putting the breakpoints I found that credential was not getting at asmx service.
Please suggest some solution.
Previous Approach I Took:
I ran into a similar issue. I have an MVC Core web application (targeting .NET Framework 4.6.1) and was not able to add a Web Reference the way I used to be able to within previous (non-Core) applications. I was not able to get Connected Services to add a reference to an asmx and allow for the passing of credentials.
To work around this, I created an additional project (a class project also targeting .NET Framework 4.6.1). From there I was able to add a Web Reference the way one could in the past. Within this project I created a class with a publicly accessible method that calls the asmx service.
Then, within my MVC Core project, I set a reference to this additional project and am able to call the public method on the other project.
Latest and Best Approach I Have Found:
I fully updated VS 2017 as well as going to this site to get the latest WCF Connected Services extension (https://marketplace.visualstudio.com/items?itemName=WCFCORETEAM.VisualStudioWCFConnectedService).
The AuthorizationSoapHeader was easy to access and set.
MySoapClient.EndpointConfiguration endpoint = new MySoapClient.EndpointConfiguration();
MySoapClient myService = new MySoapClient(endpoint, myURL);
AuthorizationSoapHeader MyAuthHeader = new AuthorizationSoapHeader();
MyAuthHeader.AppName = FDSServiceAppName;
MyAuthHeader.AppID = Guid.Parse(MyAppID);
Entry[] entries = MyService.GetUsers().Result;
I faced the same problem and i resolved it owning to github issues :
In Reference.cs substitute
System.ServiceModel.BasicHttpBinding result = new System.ServiceModel.BasicHttpBinding()
for
System.ServiceModel.BasicHttpBinding result = new System.ServiceModel.BasicHttpBinding(System.ServiceModel.BasicHttpSecurityMode.TransportCredentialOnly);
result.Security.Transport.ClientCredentialType = System.ServiceModel.HttpClientCredentialType.Basic;
This really worked in .net core client app for soap web services

Server Side / Cloud Coding for the app?

I am am making an app for iOS & Android whose frontend UI is ready. Now I wanted to learn some server side coding to connect my backend with Amazon services.
MY app will feature 1.image upload & download 2. storing of data and meta data 3. user registration and stuff
I have no clear idea about server side and cloud coding ? so want you guys push me a bit from where should I begin and how should I begin to make the above features for my app working ?
It sounds like you are looking to do mobile app development that works with cloud datastores.
Here are a few blogs that you can take a look at get started with:
http://mobile.awsblog.com/post/TxERCU1UMRFNPB/DynamoDB-on-Mobile-Part-5-Fine-Grained-Access-Control
The above blog post talks about using AWS Mobile SDKs with DynamoDB. In general, mobile.awsblog.com has more resources for developing with other datastores and might be a good resource. For DynamoDB's support for enabling mobile developers to build serverless architectures, please take a look:
http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/FGAC_DDB.html
Hope this helps.
Swami
If you have no clear idea about server side coding maybe you should use a backend-as-a-service platform such as Backbeam. These platforms give you SDKs for iOS and Android typically and you don't have to worry about the servers stuff. You can create a database in the control panel and start using it from your iOS apps making queries, inserting data, etc. You have also other features such as push notifications, users authentication, and more.
Disclaimer: I work at Backbeam. Other well-known platforms are parse and kinvey

How can I login programmatically into Sitecore?

How can I login programmatically into Sitecore?
For example if you would like to connect a small part of the Sitecore API to a desktop application, you would need to login into sitecore first to access the databases etc.
Can this be done?
As Mark said, you will need to create a web service that your desktop app will talk to. If you need to deal with permissions in that service you have two options.
Use a SecurityDisabler to make your webservice run in the context of an Admin user.
using (new Sitecore.SecurityModel.SecurityDisabler())
{
// do stuff here
}
For more specific control you can use a UserSwitcher.
From the Security API Cookbook page 34
string domainUser = #"domain\user";
if (Sitecore.Security.Accounts.User.Exists(domainUser))
{
Sitecore.Security.Accounts.User user =
Sitecore.Security.Accounts.User.FromName(domainUser,false);
using (new Sitecore.Security.Accounts.UserSwitcher(user))
{
//TODO: code to invoke as user
}
}
Not really. What you can do, however, is write a supporting web service for your desktop application, and have that run in a Sitecore context.
There is an easier way to accomplish your goal:
Create a desktop application and
reference the same version of the
Sitecore binaries that your web app
uses.
Configure your desktop application
to point to the same Sitecore DBs as
your web site.
Use the security disabler and then
set the context as follows:
Sitecore.Context.SetActiveSite("website");
Sitecore may tell you that what you are trying to do will not work. But trust me, this works and I've used this method in a project before.
Additional details:
Sitecore uses the Master, Core and Web DBs as it's data store. My suggested method uses Sitecore APIs to write directly to the DBs. When using this method, you'll need to be aware of the cache implications.
cheers!

Consuming a web service with the Netbeans Platform

I have an application that is written with the NetBeans Platform 5.5. I'm having trouble consuming a web service.
If I create a Java SE application in NetBeans, I can add a web service reference without problem.
Since my application is using the NetBeans Platform, many of the menu choices change. So, I cannot figure out how to add a reference to the web service. I've googled this topic a number of ways but haven't found any pages that deal with consuming a service through the platform. They all talk about consuming a service with a Java SE application.
Changing the application from the Platform architecture is not an option.
Here is a good tutorial for setting up a Feed Reader on NetBeans Platform. It covers some of the configuration issues for using web services
Blog with an entry about making a web services client
I'd be happy to try and give you a more specific answer if you can give information about the service you want to access.
Found this:
Create web service and client using this tutorial
Create library wrapper module for web service client (you don't need to include JAX-WS libs, only your client jar)
In your wrapper module add following dependencies (important):
JAX-WS 2.1 API
JAX-WS 2.1 and JAXB 2.1 Library (for this you have to check Show Non-API Modules in "Add Module Dependency" window)
If you try to build module after these steps it will fail telling you that your module is not friend of "path-to-netbeans"/java2/modules/org-netbeans-modules-websvc-jaxws21.jar.
Right click on JAX-WS 2.1 and JAXB 2.1 Library and choose Edit. Select Implementation Version.
from here.