Posts

Showing posts with the label Azure

Be aware of the case sensitive "Redirect URL" in Azure Active Directory App settings

When you create a new App in Azure Active Directory App settings, and then setup the "Authentication"->"Add platform" such as ("Web") -> add a redirect URL. Now go back to your client side applications either Web or mobile app, and then add the call back URL to the configuration settings. If you add the URL is  upper or lower case different from the one in App settings, then you will receive the error "Incorrect URL" from Azure, and so make sure enter the URL as same as the settings in Azure. 

Setup Azure Pipeine for SharePoint SPFx

I followed this article https://www.youtube.com/watch?v=8gQFUQzDzSs to setup the Azure pipeline for packaging and deploying SPFx to SharePoint Online. My Repos name contains space between words. When the pipeline executes the "gulp bundle" step,  there is error message from webpack that unable to find some css resources. I did some research in the Internet and fount out that webpack behaviors different in windows and Linux. The above video used the linux platform but I work on windows PC to build and package the SPFx. So once I change the platform to windows with the line of code " vmImage :  'windows-latest' ", the "gulp bundle" step passing the CSS error! However, it always shows error "exited with code 1" at the end and caused the pipeline failure. To resolve this issue, I refer to this https://www.eliostruyf.com/how-to-let-the-warnings-not-fail-the-sharepoint-framework-build-process/ and then added following code to gulpfile.js // ...

Resolve error :"Unable to resolve module `crypto` in \\azure-mobile-apps-client\\node_modules\\node-uuid\\uuid.js''

I met issue "Unable to resolve module `crypto` in \\azure-mobile-apps-client\\node_modules\\node-uuid\\uuid.js'" when I developed an App using React Native and Azure Mobile App Service. The Azure Mobile App Service uses the crypto module in "uuid.js" such as "require('crypto').randomBytes", because crypto is a core Node JS module, and the React Native packager can’t package it along with app’s Javascript bundle, so it throws a runtime error: Unable to resolve module 'crypto'. I did a research on google.com, and fount out this article " Using Core Node JS Modules in React Native Apps ". Based on this article, I came out a solution to resolve this problem as below. npm install -g browserify  Create a file  crypto-in.js  that imports the  crypto  module and simply exports it:  var crypto=require("crypto"); module.exports=crypto;  Create a standalone Javascript bundle   crypto.js  using  browserify in NPM ...

Javascript - Equivalent of .NET DateTime.MaxValue.Ticks

According to article "Azure Storage Table Design Guide: Designing Scalable and Performant Tables" " https://docs.microsoft.com/en-us/azure/cosmos-db/table-storage-design-guide#log-tail-pattern ". The below code is used to store the entities using a RowKey that naturally sorts in reverse date/time order by using so the most recent entry is always the first one in the table. string invertedTicks = string.Format("{0:D19}", DateTime.MaxValue.Ticks - DateTime.UtcNow.Ticks); The Equivalent JavaScript code is as below: var currentTimeInMilliseconds=moment().add(-2, 'hours').valueOf() * 10000 + 621355968000000000; //MaxTime is the DateTime.MaxValue.Ticks var MaxTime = 3155378975999999999; var rowKey =(MaxTime - currentTimeInMilliseconds).toString();

Handle "Forgot your password" / "Reset password" in Azure B2C Activity Directory "SignInSignUp" policy

Image
When you use Azure B2C Activity Directory "SignInSignUp" policy in your application, then you will see below screen shot signin /signup pop up window. If you click on "Forgot your password?", and the login is failure at this code " await PublicClientApp.AcquireTokenAsync(Scopes, GetUserByPolicy(PublicClientApp.Users, PolicySignUpSignIn), UIBehavior.SelectAccount, string.Empty, null, Authority) ;". You can catch this error and the error message should contains "AADB2C90118", and then you can handle this error to invoke "Reset Password Service" with following code:  AuthenticationResult authResult= await PublicClientApp.AcquireTokenAsync(Scopes, GetUserByPolicy(PublicClientApp.Users, PolicySignUpSignIn), UIBehavior.SelectAccount, string.Empty, null, AuthorityResetPassword);    You can retrieve user name and "id_token" from "authResult" from above code. Refer to Azure B2C sample project " https://github.com...

Some tipts to Embeded PowerBI report in a Azure Web App

I follow the sample " https://github.com/guyinacube/PowerBI-Developer-Samples " - "Apps Owns Data" to allow external users to access internal PowerBI data. I got error 'Unauthorized' when try to access it by the given report group Id. I checked with the BI guys that the workspace in PowerBI is created as public or private mode. It should be public mode. In addition, you need to grant relevant permissions to the app registered in the Azure AD. Do this with a AZure Admin account. Refer to below lessons. https://community.powerbi.com/t5/Developer/Power-BI-Embedded-authentication-error/td-p/197670 https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-authentication-scenarios

Retrieve records from Azure Service Bus queue but not deleting data

Image
I followed below sample from " https://github.com/noodlefrenzy/node-amqp10 " to retrieve records from Azure Service Bus queue.  However, all data were deleted after run the code.  const AMQPClient = require('amqp10').Client; const Policy = require('amqp10').Policy; const protocol = 'amqps'; const keyName = 'RootManageSharedAccessKey'; const sasKey = 'your_key_goes_here'; const serviceBusHost = 'namespace.servicebus.windows.net'; const uri = `${protocol}://${encodeURIComponent(keyName)}:${encodeURIComponent(sasKey)}@${serviceBusHost}`; const queueName = 'partitionedQueueName'; const client = new AMQPClient(Policy.ServiceBusQueue); client.connect(uri) .then(() => Promise.all([client.createReceiver(queueName)])) .spread((receiver) => {     console.log('--------------------------------------------------------------------------');     receiver.on('errorReceived', (err) => {         // check for er...

Generate "session" object using bot.loadSession()

I need to send a reminder message within a function which outside "bot.dialog()". This function is triggered by a HTTP post event and so no "session" parameter will be passed in. I want to create a "HeroCard" message which needs "session" object. I search around in google and then found out the solution which is using "bot.loadSession()". You need to pass in the message address (session.message.address) to this function. The sample code is as below: var msg = new builder.Message().address(address); bot.loadSession(address, (error, session) => {  msg.attachments([  new builder.HeroCard(session)  .title(title)  .text("XXXXX")  .images([builder.CardImage.create(session, "imageURL")])  .buttons([ builder.CardAction.openUrl(session, "actionURL", "XXXX") ]) ]);  session.send(msg); });

Azure Bot Framework: using URL to send poactivate message (Node.js)

Firstly create a chatbot using Azure Bot framework and then deploy to github and web app (Refer to this article https://github.com/fuselabs/echobot ). Using the function to send poactivate message based on this sample https://github.com/Microsoft/BotBuilder-Samples/blob/master/Node/core-proactiveMessages/simpleSendMessage/index.js Note: the function "sendProactiveMessage" must placed before the "server.get"code.  function sendProactiveMessage(address) {   var msg = new builder.Message().address(address);   msg.text('Hello, this is a notification triggered by url');   msg.textLocale('en-US');   bot.send(msg); } server.get('/api/custom', function(req, res, next) {   sendProactiveMessage(savedAddress);   res.send('home: ')   return next(); });  Before using above web app,  I used the Azure bot service to create a bot and then modified the code to add poactivate function. However, it didn't work and so I changed to use Azure...

Node.js - Get return value from call back function with Azure Bot Framework

I have been started to built a chatbot using node.js within Azure Bot Framework. I need to get return value from a HTTP request's response result. I was using the "normal" way of function (callback){} in node.s, but no luck to get the return result. I did a research and then found out this article " Microsoft Bot Framework Node SDK and LUIS ". Refer to this article, I finally work out the way of getting return value as below. var rp = require('request'); bot.dialog('SearchHotels', [  function (session) {    var destinationUrl="XXXX";   callRemoteSite(destinationUrl, (responseString) => {             session.send(responseString);      }); } function searchHotels(destinationUrl, callback) {  rp(destinationUrl, function(error, response, body) {           var json= parseFinance(body);          callback(json);   }) } The advantage of above function is you can...

Registered Tags are droped by Azure Push notification hub

I have been met a strange issue that the registered Tags are dropped by Push Notification hub in some time after registered successfully in Azure. I use the installation mode to register Tags via a controller function in Mobile App back-end service. I can see those tags are added to the hub via the server explorer within Visual Studio. After few days, I run the app again and unable to receive the push notification message target to those tags anymore, and so I went to the server explorer and found those tags are gone!   After investigation, I found the issue was caused by following code: // Register the channel URI with Notification Hubs.  await App.MobileService.GetPush().RegisterAsync(channel.Uri);  As I didn't provide the template contains tags, and so the register function remove those tags from the hub. After remove above the line, the app can receive message consistently and those tags are there forever now. However, if I run above code after regi...

Enable scheduled push notification in Azure

The scheduled feature of Push notification hub in Azure is not available in "Free" and "Basic" pricing tier, and so if you need to send scheduled push notification message, then choose "Standard" pricing tier.

Could not load file or assembly 'Newtonsoft.Json'..." error causes Azure Push Notification initinalize failure in Windows Appp

I have been received the error "HTTP 400, bad request" when calling Azure Push Notification initialised function for few days. It was working fine previously and I didn't change any configuration on it. I checked the "diagnostics logs" in Azure Mobile App service and found the issue related to below error message. Could not load file or assembly 'Newtonsoft.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) I researched above issue in Google and then updated the latest version of "Newtonsoft.Json" in my Azure Mobile App .NET back-end application. The issue was gone and I can calling Azure Push Notification service in my mobile App successfully!

Using native Facebook App's authentication to login to Azure Mobileservice in Universal Windows App

I used the "Facebook authentication" in Azure Mobile App service but it requires user to enter Facebook credential to login by default, and so I need to get the user token from native Facebook app and then pass it to Azure App service.  Below is the code I used to retrieve user token from native Facebook app. It will redirect user to native Facebook App to authenticate. string fbAppId = "xxxxxxxxxx"; string fbWinAppId = "xxxxxxxxxxxxx"; string FacebookURL = "https://www.facebook.com/v2.7/dialog/oauth?client_id=" + fbAppId; string callBackURL = WebAuthenticationBroker.GetCurrentApplicationCallbackUri().AbsoluteUri; string token = string.Empty; FacebookURL += "&redirect_uri=" + System.Uri.EscapeDataString(callBackURL) + "&display=popup&response_type=token&state=1&scope=email";  System.Uri startURI = new Uri(FacebookURL);  System.Uri endURI = new Uri(callBackURL);  var resultFB = await  Windows.Sec...

How to update device Installation's tags in Azure Mobile App Service .NET backend

It mentions that how to add Tags to Installation in this sample article https://blogs.msdn.microsoft.com/writingdata_services/2016/01/22/adding-push-notification-tags-from-an-azure-mobile-apps-client/ . But I need to update my tags in device installation not just adding new tags, and so I comment out the line of code "await hubClient.PatchInstallationAsync(Id, updates);", and then add following codes in my custom API controller in .NET backend.                // Verify that the tags are a valid JSON array.                 var tags = JArray.Parse(message);                 List<string> validTags = new List<string>();                 foreach (string tag in tags)                 {                          ...

A real time Notification App to engage the business promotion with customer in a personalized, cost effective and interactive way

Image
Today’s reality is that the average person is: Bombarded with hundreds of emails  Time-poor has not got the time to read emailed advertising materials As a business marketer, your  email promotional activity needs to produce positive results. Your online promotional strategies need to break through the cyber-clutter to become more profitable and more successful. This is why I come up with an App idea to engage the business promotion with customer in a more personalized, cost effective and interactive way by using interactive notification message and Facebook chat-bots. Below are the screenshot of notification message on desktop and chat-bots. I worked with Madhan K from Qantas in "AngelHack Sydney 2016" event recently to make a Notification App provides subscription services to customers to subscribe and receive the push notification of latest promotion from a most popular business around the customer area based on the real time number of Optus mobile us...

Using Azure service to delivery message to mobile and Windows Store Apps

Image
Azure Notification Hubs provide the feature to send push notifications to a Mobile App including iOS application, Android application, Windows Store or Windows Phone 8 application. First of all, you need to create a notification hub in Azure portal . Secondly, you need to build a mobile application to connect to the notification hub and also receive message from it. You can send notifications by using Notification Hubs from any backend via the REST interface . This scenario can be used in different cases such as Error message notification, Timesheet reminder, etc. Below is a screenshot of a sample notification in Windows Phone, and it would be extended to Windows store desktop App as well. The detail tutorial is in here . In addition, you can use Azure Mobile service to send notification when end user add / update /delete data in Azure database.

SQL Server 2012 AlwaysOn supports with Windows Azure Virtual Machines

Microsoft recently announced "SQL Server 2012 AlwaysOn supports with Windows Azure Virtual Machines". SQL Server 2012 AlwaysOn enables high availability and disaster recovery with SQL Server. It's a descendant of Database Mirroring and available only in SQL Server Enterprise. Any Database server that runs SQL Server 2012 Enterprise Edition can use AlwaysOn Availability Groups by joining a cluster and configuring the availability group.  It does not require shared disk storage, but requires special hardware and configuration steps to set up Failover Cluster Instances. For more information about these features, see Microsoft SQL Server AlwaysOn Solutions Guide for High Availability and Disaster Recovery .