azure notfication hub registration time to live - azure

How can I change the time to live for a registration (default = 90 days) on azure notificationhub?
I only found this article where it is mentioned:
https://github.com/Azure/azure-content/blob/master/articles/notification-hubs/notification-hubs-registration-management.md
For registration on mobile devices I use the AzureMessaging component:
https://components.xamarin.com/view/azure-messaging
I didn't find any settings on the azure portal.
In the component-library I found the ExpirationTime of a Registration but it is readonly. The Registration-Class is also protected so I don't have access.
var registration =_hub?.Register(registrationId, tags.ToArray());
var thisIsReadOnly = registration.ExpirationTime;
Thanks for any advice.

Currently you can only set the TTL for APN templates using the expiry element.
<?xml version="1.0" encoding="utf-8"?>
<entry xmlns="http://www.w3.org/2005/Atom">
<content type="application/xml">
<AppleTemplateRegistrationDescription xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/netservices/2010/10/servicebus/connect">
<Tags>myTag, myOtherTag</Tags>
<DeviceToken>{DeviceToken}</DeviceToken>
<BodyTemplate><![CDATA[{Template for the body}]]></BodyTemplate>
<Expiry>{Template for Expiry in }</Expiry>
</AppleTemplateRegistrationDescription>
</content>
</entry>
ref: Create Registration
However keep checking the documentation for updates this may change.

Related

How to cleanly automate authentication for Azure Devops feeds?

Presumably there are lots of companies who are facing the same struggle we are.
For any microservice, before running a dotnet restore we need to first ensure we've successfully configured our ADO package feeds with an active token.
To achieve this we have a script which downloads and runs the CredentialProvider.VSS.exe (as suggested by Microsoft), using the output to build credentials which then register the feeds on the user's computer. This needs to happen daily as the tokens generated will expire.
The script above is ugly and worse yet, every repository needs it in order to ensure feeds are configured with active tokens. Even if we moved the ugly script to a PowerShell module for example, how would we authenticate against the PS feed in order to download that module?
I don't see why the CredentialProvider is neccessary, why can't nuget just prompt us for credentials whenever our token expires? Has anyone come up with a cleaner solution out there which manages authentication to ADO feeds across multiple repositories?
How to cleanly automate authentication for Azure Devops feeds?
To authentication for Azure Devops feeds, you could try to use the NuGet authenticate task, which configure NuGet tools to authenticate with Azure Artifacts and other NuGet repositories.
Then we could create a new NuGet service connection with PAT:
You can use a longer-term PAT for certification, so you don't have to change certification every day.
another approach using nuget.confg as below
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="AzureDevOpsFeed" value="https://pkgs.dev.azure.com/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/index.json" />
<add key="nuget" value="https://xxxxxxxxxxxxxxxxxxxxx/index.json" />
</packageSources>
<packageSourceCredentials>
<VSTSFeed>
<add key="UserName" value="#{PAT_UserName}#" />
<add key="ClearTextPassword" value="#{PersonalAccessToken}#" />
</VSTSFeed>
</packageSourceCredentials>
</configuration>

Where can I download a *.publishsettings file for vNext in the new Azure portal?

Apologies for the long question, but I think some context is important here.
I am trying to set up a release definition within TFS, which should be supporting Azure deployment by using the "Azure Web App Deployment" step (see picture).
For this to work, I need to set up a Service Endpoint. However, I'm having issues at the point of retrieving the Management Certificate requested here:
There seem to be multiple places in the new portal (https://portal.azure.com) to download a *.publishsettings file, for example here:
The issue
For some reason, all these downloads return a *.publishsettings file with the following format:
<publishData>
<publishProfile profileName="XXX"
publishMethod="XXX"
publishUrl="XXX"
msdeploySite="XXX"
userName="XXX"
userPWD="XXX"
destinationAppUrl="XXX"
SQLServerDBConnectionString=""
mySQLDBConnectionString=""
hostingProviderForumLink=""
controlPanelLink="http://windows.azure.com"
webSystem="WebSites">
<databases />
</publishProfile>
<publishProfile profileName="XXX"
publishMethod="XXX"
publishUrl="XXX"
ftpPassiveMode="XXX"
userName="XXX"
userPWD="XXX"
destinationAppUrl="XXX"
SQLServerDBConnectionString=""
mySQLDBConnectionString=""
hostingProviderForumLink=""
controlPanelLink="http://windows.azure.com"
webSystem="WebSites">
<databases />
</publishProfile>
</publishData>
The format that I require is different. I need a file with this format:
<?xml version="1.0" encoding="utf-8"?>
<PublishData>
<PublishProfile
SchemaVersion="2.0"
PublishMethod="AzureServiceManagementAPI">
<Subscription
ServiceManagementUrl="XXX"
Id="XXX"
Name="XXX"
ManagementCertificate="XXX" />
</PublishProfile>
</PublishData>
From this file, I can retrieve the ManagementCertificate value. I can already retrieve it from the old portal using https://manage.windowsazure.com/PublishSettings/index?Client=&SchemaVersion=&DisplayTenantSelector=true, but there does not seem to be a place for this in the new portal. Is it not available, or did I simply overlook it?
Thanks in advance!
Hi Tybs is there a reason you are not creating a Service Principal with a management certificate that you can then use? In your screenshot there is a link on how to use Service Principal which as Guarav pointed out is the way to connect for ARM.
https://learn.microsoft.com/en-us/azure/azure-resource-manager/resource-group-authenticate-service-principal
The link is already provided in the endpoint dialog, clicking it, you will get the publish settings you want:

Remove Server:HTTPAPI/2.0 header on invalid request

I'm trying to stop MS Azure responding with the header/value of Server: HTTPAPI/2.0 on receipt of an invalid request, for example an invalid hostname.
I've seen this SO entry...
Removing Server and X-Powered-By HTTP Headers on Azure Web Site Preview
..and one answer suggests that the only way to get around this is to host the website on an Azure VM, something I'd much rather avoid.
It's 3.5 years on from that question/answer - does anyone know if it can now be suppressed in a WebApp solution
According the description at Remove standard server headers in Azure Web Sites:
HTTP headers are part of the communication process between web servers and browsers, and are included in the request and response. One example is the server header, which lists the product name and version of the web server (e.g., Microsoft-IIS/8.0). All web servers generate these headers, but now you can disable them on Azure Web Sites.
You can try to modify or create a new web.config in the root directory of your application on Azure Web Apps, with following content:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<security>
<requestFiltering removeServerHeader="true" />
</security>
</system.webServer>
</configuration>
Please refer to https://azure.microsoft.com/en-us/blog/removing-standard-server-headers-on-windows-azure-web-sites/ for more info.
To remove the MVC header, add this in Global.asax - Application Start event:
MvcHandler.DisableMvcResponseHeader = true;
Using this will remove the version headers,
<httpRuntime enableVersionHeader="false" />

What does the following Azure Notification Hub REST response mean: 'The specified resource description is invalid.'?

I am trying to register my Windows Universal App for notifications from the Azure Notification Hub through our Java backend service.
I debugged the app from Visual Studio, while it was running on my Windows Phone device. The app could properly get a ChannelUri and passed it along to our Java backend. (I ran the backend on my local PC.)
The Java backend generated the following request for a template registration and tried to send it to the Azure REST Api:
<?xml version="1.0" encoding="utf-8"?>
<entry xmlns="http://www.w3.org/2005/Atom">
<content type="application/xml">
<WindowsTemplateRegistrationDescription xmlns="http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<Tags>Windows,10204394042027091,broadcast</Tags>
<ChannelUri>https://db3.notify.windows.com/?token=AwYAAABXiUp%2bD8v1%2bVfWbWLr3FZ3rQcJtPkUgFwaiGZus4GbtkM8zbZ6uQt1NKXpC4FOtYWHDxXvBb3FkoefaozvCYTFiDjhdb3jDuORUDY8zBlkGw1MxY0QjrH7G0fFbW0RXgo%3d</ChannelUri>
<BodyTemplate><![CDATA[{...}]]></BodyTemplate>
<WNSHeaders>
<WNSHeader>
<Header>X-WNS-Type</Header>
<Value>wns/raw</Value>
</WNSHeader>
</WNSHeaders>
<TemplateName>geoinfo</TemplateName>
</WindowsTemplateRegistrationDescription>
</content>
</entry>
In my opinion this is according to the MS Azure REST reference: http://msdn.microsoft.com/en-us/library/azure/dn223265.aspx
Still, the response contains the following error:
<Error><Code>400</Code><Detail>The specified resource description is invalid..TrackingId:4ffaabcc-c7f8-4a6c-ab2f-4f65e94427df_G16,TimeStamp:10/21/2014 9:42:52 PM</Detail></Error>
Any ideas on what Azure's issue is around here?
Try this:
Call Create Registration ID
Store retrieved id in your DB
Call Create or Update Registration to create registration
Each time you want to update that registration in future (refresh channel, modify tags...) you just call Create or Update Registration again
I've just successfully played with payload bellow:
<?xml version="1.0" encoding="utf-8"?>
<entry xmlns="http://www.w3.org/2005/Atom">
<title type="text"></title>
<updated>2014-10-21T23:57:08Z</updated>
<content type="application/atom+xml;type=entry;charset=utf-8">
<WindowsTemplateRegistrationDescription xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/netservices/2010/10/servicebus/connect">
<Tags>t1,t2</Tags>
<ChannelUri>https://db3.notify.windows.com/?token=AwYAAABXiUp%2bD8v1%2bVfWbWLr3FZ3rQcJtPkUgFwaiGZus4GbtkM8zbZ6uQt1NKXpC4FOtYWHDxXvBb3FkoefaozvCYTFiDjhdb3jDuORUDY8zBlkGw1MxY0QjrH7G0fFbW0RXgo%3d</ChannelUri>
<BodyTemplate><![CDATA[<?xml version="1.0" encoding="utf-16"?><root></root>]]></BodyTemplate>
<WnsHeaders>
<WnsHeader>
<Header>X-WNS-Type</Header>
<Value>wns/raw</Value>
</WnsHeader>
</WnsHeaders>
<TemplateName>MyTemplate</TemplateName>
</WindowsTemplateRegistrationDescription>
</content>
</entry>
The error message apparently means that the request is missing required XML elements.
The problem in my case was the capitalization:
Both WNSHeader and WNSHeaders should be written in Pascal case instead: WnsHeader and WnsHeaders.
Unfortunately Microsoft's documentation on the API is misleading regarding this.

Authorization token passed by user Invalid. Azure Cache

Maybe I'm misunderstanding how to create a cache but none of the the IDs or Access keys is working on the to enable the azure cache. I've gone through the following tutorials:
http://msdn.microsoft.com/en-us/library/windowsazure/gg618003.aspx
http://msdn.microsoft.com/en-us/wazplatformtrainingcourse_buildingappswithcacheservice_topic3#_Toc310505080
http://msdn.microsoft.com/en-us/library/windowsazure/gg618003.aspx
And about 1/2 a dozen different how to create a cache in azure pages and I'm still getting.
Authorization token passed by user Invalid.
I've got a website and cloud service with linked storage and nowhere can I find a url "yourcachename.cache.windows.net" or an Authentication Token in the manage Azure portal. Any suggestions would be greatly appreciated.
It turns out that I was getting confused between versions of Azure. I'm not sure what version this started in but I was working in 1.8 and I did not need an access key. Once I added the below sections to the web.config everything worked.
<dataCacheClients>
<dataCacheClient name="default">
<autoDiscover isEnabled="true" identifier="{your cache worker role}" />
<localCache isEnabled="true" sync="TimeoutBased" objectCount="100000" ttlValue="300" />
</dataCacheClient>
</dataCacheClients>
<cacheDiagnostics>
And then in order to get Sessions to work I needed to add this:
<sessionState mode="Custom" customProvider="AFCacheSessionStateProvider">
<providers>
<add name="AFCacheSessionStateProvider" type="Microsoft.Web.DistributedCache.DistributedCacheSessionStateStoreProvider, Microsoft.Web.DistributedCache" cacheName="default" dataCacheClientName="default" applicationName="AFCacheSessionState"/>
</providers>
</sessionState>
You need to login to the old portal via the link on the new portal, click on shared caching, service bus and access control. Create/Select a namespace and the auth token would be displayed on the right hand side bar.

Resources