Giter VIP home page Giter VIP logo

jjazure-relaywcf's Introduction

WCF service with Service Bus Relay

WCF Service for getting image via Azure Relay.
The reason is to "publish" .Net REST WCF service via Azure Relay. There no direct publishing of this service. Service is using WCF Relay binding to publish it. You need no firewall port publishing, communication is started from backend via HTTPS. Client is calling Azure Relay service.
Solution is created on full DotNet. DotNetCore is not supported right now, see discussion.

Create Service Bus Relay

Simply create in Azure portal new service called Relay, follow this link

Change configuration

Change Key in app.config

Section system.serviceModel\behaviors\endpointBehaviors\behaviortransportClientEndpointBehavior\tokenProvider

<sharedAccessSignature keyName="RootManageSharedAccessKey" key="KEY" />

Section appSettings

<add key="Microsoft.ServiceBus.ConnectionString" value="Endpoint=sb://<yournamespace>.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=KEY" />
<add key="RelayServiceNamespace" value="<yournamespace>"/>

Test service anonymous

If you want test service in browser, change Authorization to None in app.config Section system.serviceModel\bindings\webHttpRelayBinding\binding

<security relayClientAuthenticationType="None" />

Run browser with your url, my example: https://jjrelay.servicebus.windows.net/Image/GetImage
You will get image.

Test service with security token

Check app.config for using token Section system.serviceModel\bindings\webHttpRelayBinding\binding

<security relayClientAuthenticationType="RelayAccessToken" />

Next fill correct Key into client configuration

<add key="ClientKeyName" value="RootManageSharedAccessKey" />
<add key="ClientKey" value="J9Qr7OQQI6JL3cRc6jX0yduBz3El4cVcM1x/w/le9FQ=" />

Configuration for policy Client Image

When you run server, you will get token. Call this service with token. I'm using Postman to testing service - put token in Authorization header.

GET /Image/GetImage HTTP/1.1
Host: jjrelay.servicebus.windows.net
Authorization: SharedAccessSignature sr=https%3a%2f%2fjjrelay.servicebus.windows.net%2fImage%2f&sig=WUHK8w2a698NvCXSGQffEmqPJlBZuJxYdJXewM4a%2fC8%3d&se=1517055215&skn=RootManageSharedAccessKey

Example Image

Azure WebApp with AAD authentication

This simple web application is using Azure Active Directory (AAD) for authentication. User profile page shows information about authenticated user, like User principal name (UPN). I'm using my AAD jjdev.onmicrosoft.com already created in this example.

Configure Azure Active Directory

Add new Azure Active Directory application in App registrations blade (app type is Web app). Setup permissions for Azure Active Directory - Read directory data & Sign in and read user profile. Finally setup Reply URLs based on enviroment where is web hosted. For more information follow link.

Change configuration

We need to update web.config with values for new created application in AAD.

    <add key="ida:ClientId" value="<guid<" />
    <add key="ida:ClientSecret" value="<secret>" />
    <add key="ida:Domain" value="jjdev.onmicrosoft.com" />
    <add key="ida:TenantId" value="<directoryId>" />

WCF service with Service Bus Relay hosted in IIS

Hosting WCF service in IIS for Azure Service Bus Relay is not working now. Comming back with update.

jjazure-relaywcf's People

Contributors

jjindrich avatar petersladek avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.