Quantcast
Channel: MSDN Blogs
Viewing all 35736 articles
Browse latest View live

Keeping Your Reports Up to Date with Scheduled Data Refresh

$
0
0

You can automatically keep your workbooks up to date using the scheduled refresh functionality in Power BI for Office 365 sites. This blog post provides an overview of how the feature works, and links to a few different related pages in the Office 365 online help.

Enabling refresh

After you’ve saved your workbook to your Power BI site, you can configure scheduled data refresh by click on the ellipsis (…) next to the workbook, and selecting Schedule Data Refresh.

 

On the next page, you’ll select which data connections you want to refresh, configure the schedule, and enter one or more email addresses to notify if the refresh fails. You can choose to refresh one or more data connections from the workbook’s Data Model. When you configure the schedule, you can select the frequency (Daily or Weekly), and the time of day the refresh should occur.

 

Refresh history

Once your workbook has been enabled for data refresh, you’ll be able to view its refresh history. To get to the refresh history page, click on the Schedule Data Refresh option, and click on the history tab. From this page you can see when the refresh was done, whether it succeeded, and any error messages if it wasn’t able to complete. It will also tell you when the next scheduled refresh will occur, and when a refresh operation is currently running.

 

Data source configuration

Scheduled data refresh works against data sources in the cloud (like Windows Azure SQL Database and OData services), and corporate data sources on-premises. Access to these data sources will need to be pre-configured before they can be used with scheduled refresh. If a data source has not been properly configured, you’ll see it listed in the errors on the refresh history page.

To enable data refresh for cloud data sources, see the SharePoint Online help pages for using external data.

To enable data refresh for on-premises data sources, see the Power BI Admin Center help pages for Creating a Data Source and Enabling Cloud Access.

Note - scheduled data refresh doesn’t work with all data sources that you can connect to using Power Pivot and Power Query. You can find a list of supported data sources in the Office 365 help pages.

More information

Please see the following entries in the Office 365 online help for more details on scheduled data refresh in Power BI.


Top 10 Microsoft Developer Links for Wednesday, February 12, 2014

$
0
0

Fill’r up please! The canvas msFillRule API

$
0
0

Up until now, when you create a filled shape using canvas path methods, your choice of how it looks when you use the fill method were limited to one choice: the nonzero fill rule.

With Internet Explorer 11, you now have two choices, nonzero and evenodd. Here’s how it works.

The fill rule impacts how a shape gets filled. When you create a shape with a path, nonzero and evenodd fill rules are algorithms that check whether a point is inside or outside the enclosed shape. To figure this out, the nonzero rule specifies that you pick a point in the shape, and draw a ray out to infinity (or at least outside the shape). Starting at the chosen point, and with a count of zero, you add a one each time the ray crosses a path that goes from left to right. If the path goes from right to left, you subtract a one. If the result is zero once the counting is complete, then the point is outside the path, otherwise it's inside.

Here’s a diagram that explains what we mean by right to left and left to right. The arrows show the direction of the lines.  

ctx.moveTo(200, 110);
ctx.lineTo(50, 110);
ctx.lineTo(300, 310);
ctx.lineTo(200, 10);
ctx.lineTo(100, 310);
ctx.lineTo(350, 110);
ctx.lineTo(200, 110);
ctx.stroke();
image

The evenodd rule says if you draw a ray from a point to infinity, count the number of path segments that the ray crosses. If the count is an odd number, then the point is inside the shape. If it's even, then the point is outside the shape. It doesn’t matter which way the paths are going.

 
This example shows the star getting filled in using the two different fill rules. By setting msFillRule, you can specify nonzero (the default), or evenodd.

<!DOCTYPE html>
< html>
< head>
  <title>msFillRule example</title>
  <meta />

</head>
< body>
  <h1>Fill rule example</h1>
  <h3>Click the button below to toggle between nonzero and evenodd fill rules. </h3>
  <canvas id="MyCanvas" width="400" height="400">This browser or document mode doesn't support canvas</canvas>
    < br />
    <button id="myButton">Change</button>
  <script>
    document.getElementById("myButton").addEventListener("click", draw, false);
    function draw() {
      var canvas = document.getElementById("MyCanvas");
      if (canvas.getContext) {
         var ctx = canvas.getContext("2d");
        ctx.clearRect(0, 0, canvas.width, canvas.height); // Clear area for repeated use
        ctx.beginPath();
        ctx.strokeStyle = "blue";
         ctx.lineWidth = "5"
        ctx.moveTo(200, 110);
        ctx.lineTo(50, 110);
        ctx.lineTo(300, 310);
        ctx.lineTo(200, 10);
        ctx.lineTo(100, 310);
        ctx.lineTo(350, 110);
        ctx.lineTo(200, 110);
        ctx.stroke();
        ctx.fillStyle = "yellow";
        if (ctx.msFillRule == "nonzero") {
          ctx.msFillRule = "evenodd";
          document.getElementById("myButton").innerHTML = "Change to non-zero";
        } else {
          ctx.msFillRule = "nonzero";
          document.getElementById("myButton").innerHTML = "Change to even-odd";
        }
   //     ctx.fill();
      }
    }
    draw();
  </script>

</body>
< /html>

When you run this example, you can click the button to goggle back and forth between the two rules. You’ll see:

imageThe Nonzero rule looks like this.

image
The evenodd rule looks like this.

So give it a try. For now, as a prefixed API, it’s only available in Internet Explorer 11.

TFS Client Tools

$
0
0

Here are some tools I find very handy in my day to day use of TFS. 

TitleURLDescription
Microsoft Visual Studio Team Foundation Server 2012 Power Toolshttp://visualstudiogallery.msdn.microsoft.com/b1ef7eb2-e084-4cb8-9bc7-06c3bad9148fPower Tools are a set of enhancements, tools, and command-line utilities that increase productivity of Team Foundation Server scenarios.
Team Foundation Server Administration Toohttp://tfsadmin.codeplex.comThe TFS Administration Tool allows Team Foundation Server administrators to manage user permissions on all three platforms utilized by Team Foundation Server:
  • Team Foundation Server,
  • SharePoint, and
  • SQL Server Reporting Services
TFS Team Project Managerhttp://teamprojectmanager.codeplex.comTFS Team Project Manager automates various tasks across Team Projects in Team Foundation Server. If you find yourself managing multiple Team Projects for an organization and have recurring tasks and questions that repeat themselves over and over again, Team Project Manager probably has some answers for you.
TFS 2012 Sidekickshttp://www.attrice.info/cm/tfs/index.htmTeam Foundation Sidekicks is a suite of tools for Microsoft Team Foundation Server administrators and advanced users providing Graphic User Interface for administrative and advanced version control tasks in multi-user TFS environments.
MSBuild Sidekickhttp://www.attrice.info/msbuild/index.htmMSBuild Sidekick allows you to view, edit, build and debug Microsoft Visual Studio© 2005, 2008, 2010 and 2012 project files (C#, VB.Net and C++), Microsoft Team Build project files, Visual Studio© 2005, 2008, 2010 and 2012 solution files as well as custom MSBuild projects. While providing rich Graphic User Interface, integrated build/debug and extensive logging capabilities, the application requires only .Net runtime (2.0, 4.0 or 4.5) to operate.
Work Item Query Administrationhttp://wiqadmin.codeplex.comWork Item Query Administration (wiqadmin) is command-line utility to manage work item queries in Team Foundation Server.

 

Hopefully you'll find them handy as well.

Cheers!

The worst Code Analysis Rule that’s ‘recommended’ - CA2202

$
0
0

CA2202: Do not dispose objects multiple times

How I hate this rule!

Firstly, the rule is predicated on the belief that other people will write broken code and you will have to use it. Broken how? The documentation for IDisposable.Dispose() says that it must be safe to call IDisposable.Dispose() multiple times on the same object:

“If an object's Dispose method is called more than once, the object must ignore all calls after the first one. The object must not throw an exception if its Dispose method is called multiple times. Instance methods other than Dispose can throw an ObjectDisposedException when resources are already disposed.”

It also says that only methods that are not Dispose() can throw ObjectDisposedException.

So why then CA2202? Well, let us read its documentation:

“A method implementation contains code paths that could cause multiple calls to IDisposable.Dispose or a Dispose equivalent, such as a Close() method on some types, on the same object. “

”A correctly implemented Dispose method can be called multiple times without throwing an exception. However, this is not guaranteed and to avoid generating a System.ObjectDisposedException you should not call Dispose more than one time on an object.”

What do they mean it’s not guaranteed? It is guaranteed already! IDisposable.Dispose() says so. And calling Dispose() on a object that has had Close() called should be perfectly safe too! (And would you ever do it in the other order?)

So yes, the rule as it exists is pretty flawed in concept. Because it’s telling you to fix the wrong thing. What they should do instead is help enforce the other side of the Dispose() contract. CAXYZZ: do not ever do anything that makes your Dispose() method unsafe to call multiple times. Specifically don’t write code that can throw ‘obvious’ exceptions like NullReferenceException(), ArgumentNullException(), or ObjectDisposedException() from your Dispose() method.

However, it’s not just that this rule is telling you to fix the wrong thing… if you try to follow it’s recommendations, you will often actually a) make your code look wrong (aside: Joel Spolsky is he who by his writing taught me to think about whether code ‘looks wrong’. I think this is one hell of a great concept to understand, and it really doesn’t require hungarian notation.) b) break your code.

What, break my code? Yes. Look at this diff:

// Encrypt the data as an array of encrypted bytes in memory.
-using (var memoryStream = new MemoryStream())
-{
-    using (var encStream = new CryptoStream(memoryStream, cryptoTransform, CryptoStreamMode.Write))
-    {
-        using (var sw = new StreamWriter(encStream, new UTF8Encoding()))
-        {
-             sw.Write(plainText);
-        }
-      }
-}
+var memoryStream = new MemoryStream();
+var encStream = new CryptoStream(memoryStream, cryptoTransform, CryptoStreamMode.Write);
+using (var sw = new StreamWriter(encStream, new UTF8Encoding()))
+{
+    // Write the plaintext to the stream.
+    sw.Write(plainText);
+    sw.Flush();
+    encryptedBuffer = memoryStream.ToArray();
+}

This is an attempt to satisfy CA2202. It is also a WRONG attempt to satisfy CA2202, since it introduces a bug. The bug is… (spoiling the puzzle - if you wanted to figure it out yourself…) the encrypted data returned is now empty when we encode a short test string. We actually also need to call encStream.FlushFinalBlock() in order to get the correct result.

Now luckily this bug was caught straight away by unit tests. But really why did introducing this bug happen? There is nothing wrong with the original code with 3 nested usings! The only reason the bug was introduced, is because we attempted to satisfy code analysis rule CA2202.

 

PS - when originally posted I forgot to explain what I meant about the code looking wrong.

I simply meant that it looks wrong having something IDisposable not be in a using block. When it's in a using block you automatically know that it will be disposed without doing any further reading of the code. If it's *not* in a using block, then you have to look at the code path below and consider whether there are any troublesome edge cases, whether a try/finally should have been used, and so on.

Visual Studio and Permissions

$
0
0

I’d like to thank Will Hirst (Microsoft ITSM Infrastructure
Consultant) for finding the answer to this problem.

When using Visual Studio on a machine running Windows Server
2012, even with User Access Control set to the lowest level, you may need to
start the application with administrative rights to perform some operations.

In this example, I try to manage a test agent and receive a
permissions error.

When Visual Studio is started as an administrative process

the operation is successful.

This can be frustrating as the error that’s shown isn’t
logged in Event Viewer, nor in the trace files that the controller and agent
services can create.

Windows Azure HDInsight supports preview clusters of Hadoop 2.2

$
0
0

Following the recent launch of Windows Azure HDInsight last October, we are announcing that Windows Azure HDInsight now supports Hadoop 2.2 clusters in preview.

Windows Azure HDInsight is Microsoft’s 100 percent Apache Hadoop-based distribution for Windows Azure. Hadoop is a distributed storage and processing platform that provides analysis on large volumes of both relational and non-relational data. With HDInsight, Azure customers can either leverage data in Windows Azure Blob storage or the native HDFS file system that is local to the compute nodes. You can then dynamically provision Hadoop clusters to process your data and leverage the elastic scale of Windows Azure. Read the CIO magazine spotlight that highlighted customers who are crunching large volumes of data and integrating new types of data into their analysis with HDInsight.

New in this release of Windows Azure HDInsight is an order magnitude (up to 40x) improvement to query response times, data compression (up to 80%) for lower storage requirements, and leveraging the benefits of YARN (upgrading to the future “Data Operating System for Hadoop”). Windows Azure HDInsight is also globally available across all Windows Azure datacenter locations (North America, EMEA, and Asia) with the exception of China.

To get started with Windows Azure HDInsight that supports a preview of Hadoop 2.2, visit the documentation guide here.  We invite you to learn more through the following resources:

 

Only Project and Project Server 2010 get a Cumulative Update this month


Servicebus throwing error while sending a message

$
0
0
When retrieving and sending message from or to a Windows Azure 
Service Bus Queue, once in a while you might get these two kind of error messages.

Queue.Send(message) failed: The token provider was unable to provide a security token while accessing 'https://contoso-sb.accesscontrol.windows.net/WRAPv0.9/' .

 Token provider returned message: 'The underlying connection was closed: A connection that was expected to be kept alive was closed by the server.'.

 The token provider was unable to provide a security token while accessing 'https://contoso-sb.accesscontrol.windows.net/WRAPv0.9'. 

 Token provider returned message: 'Error:Code:429:SubCode:T0:Detail:

 ACS50000: There was an error issuing a token.

 ACS60000: An error occurred while processing rules for relying party 'http://contoso.servicebus.windows.net/bangalore_2_2/' using the service identity or identity provider named 'owner'.

ACS60000: Policy engine execution error.

ACS60021: The request has been terminated by the server (tenant exceeded ratelimit).:TraceID:6be3g937-3203-24gd-691d-26g0e9j7fic5:TimeStamp:2013-07-31 03:17:23Z'.

From the description, it seems you can only acquire token for a set amount of times within a limited time frame. But that's not the case so let me explain what exactly the issue is.

If you notice the errors are being thrown by ACS and if you read my blog you would also have got a pretty good understanding of the same. Service Bus interacts with ACS as documented on  this page

http://msdn.microsoft.com/en-us/library/windowsazure/dn170478.aspx.

So in this case Service Bus is calling ACS and bubbles the error that it receives from ACS. Service Bus in this case acts like a middleware. Service Bus throws these errors to the client application so as not to mask potentially security relevant exception information from the client application. The client application would require to make the retry strategy. 

Now coming to the ACS part if you notice the timestamp is for 7/30 . We had an issue in ACS where message “tenant exceeded ratelimit” was returned to clients that did not actually exceed any rate limits. Today, this should not be the case (the bug was fixed), and this error condition will generate correct error code/message as per my blog and the msdn pages mentioned there in.  We have also reduced the load on servers by provisioning more instances and the chances of getting this error is very less now.  We have now documented the limitations of ACS service at http://msdn.microsoft.com/en-us/library/gg185909.aspx. The page with error codes http://msdn.microsoft.com/en-us/library/gg185949.aspx has also been updated for ACS90046 (ACS busy) or ACS60021.

MVPs to Present at the Microsoft Embedded Conference in Naples

$
0
0

This Saturday, five MVPs will present at the Microsoft Embedded Conference in Naples, a free event focused on embedded Microsoft technologies. With session titles like, "Is My Washing Machine Flirting with my Neighbor's Water Heater?" and "Windows 8 POS API, for Developing Point of Service Systems in a Simple and Quick Way," the event is sure to be packed full of entertainment, real world applications and deep, technical knowledge that audiences have come to expect from MVPs. We'd like to wish MVPs Valter Minute, Mirco VaniniBeppe Platania, Gianni Rosa Gallina and Marco Dal Pino "buona fortuna" on their presentations!


Is My Washing Machine Flirting with my Neighbor's Water Heater? 
By Windows Embedded MVP Valter Minute

photo


Internet of Things : Smart Home & Smart Factory systems (Part 1 and 2)
By Windows Embedded MVP Mirco Vanini

photo

Exploring Sense 3: An Example of "Intelligent System" for Showrooms, Trade Fairs and Conferences
By Windows Embedded MVPs Beppe Platania& Gianni Rosa Gallina

photophoto

Windows 8 POS API, for Developing Point of Service Systems in a Simple and Quick Way.
By Windows Embedded MVP Marco Dal Pino

photo

Live Webcast Series: MTC Philadelphia Tech Talk

$
0
0

The Philadelphia Microsoft Technology Center Is kicking off a new weekly Tech Talk series featuring interactive, one-hour technical sessions on Fridays from 12:00-1:00PM Eastern. Customers viewing the webcasts will be able to interact with presenters using an integrated Yammer, Yam Jam style, feed. All upcoming sessions are listed below. For more information on how to join the sessions, please visit the MTC Philadelphia website.

Have topics you would like to request for the Tech Talks series? Visit the Philadelphia MTC Facebook Page here, and leave the team a note with your suggestion.

We hope you will join and invite your colleagues as well.

--------------------------------------------------------------------------------------------------------------

2/21 - What's New in SQL Server 2014? - William Emmert
SQL Server 2014's mission is to deliver mission critical performance, business insights for any data and platform for hybrid cloud. During this session, we will look at what's coming in the next release. We will cover new features such as in-memory and SQL with Azure Storage Integration and enhancements to columnstore, resource governor and security.

2/28 – Lync for Developers – Teo De Las Heras
The Lync Developer platform is a powerful differentiator, used by about 1 out 4 Lync customers. This session will explain the components of the platform, how it's used by customers, and how you can get more value out of Lync investments.

3/7 – Azure for Developers 1 of 4 Introduction to Microsoft Azure for the Enterprise – Todd Furst and Danilo Diaz
Cloud Computing, Mobility, Big Data and Social Media are the four major trends in IT today. Cloud Computer is unique in that it can be used to enable the others. In this session you will learn the basics concepts of cloud computing, patterns and economic of the cloud. We will also introduce Windows Azure – Microsoft's Cloud Computing platform.

3/14 - Azure for Developers 2 of 4 Connecting Your Corporate Environment to Azure – Todd Furst and Danilo Diaz
Azure provides several options to seamlessly extend customers' network to the Azure Cloud. In this session, we will walk through common customer scenarios amd show the Azure connectivity solution that best aligns to the scenario.

3/21 - Azure for Developers 3 of 4 Azure Infrastructure as a Service (IAAS) – Todd Furst and Danilo Diaz
In this session, we will walk through scenarios showing how customers can leverage Azure's IaaS capabilities to extend their datacenter to the cloud, quickly build test/dev environments, scale on demand, etc. We will also show how System Center can provide seamless management across both Azure and customers' on-prem cloud.

3/28 - Azure for Developers 4 of 4 Azure for Developers – Todd Furst and Danilo Diaz
Windows Azure is powerful platform that enables developers to build solid enterprise ready applications that are reliable and scalable. In this session will walkthrough some of the application building blocks available in Azure as well as some of the other services that can help developers thought the entire application life cycle.

4/4 – Enterprise Social with SharePoint, Yammer, and Azure Media Services – Michael Gannotti
Enterprise Social Media is hot and Microsoft is bringing the social heat. In this session learn how Microsoft brings together all the aspects of rich social media in an integrated fashion that can help your organization work smarter, faster, more efficiently.

WHY CENTRAL MERGE SUBSCRIBERS ARE NOT SUPPORTED

$
0
0

Holger Linke
Microsoft SQL Server Escalation Services

Abstract

Provides details and explanations why SQL Server Merge Replication does not support central subscriber topologies. This fact was originally stated in SQL Server Books Online and further documented in KB article KB 2750005, but is still causing some misconceptions and confusion.

This blog article will provide additional thoughts and background information about why configuring central subscribers with Merge Replication is not a good idea.

The Central Subscriber model

In a central subscriber model, the subscriber database synchronizes with two or more publishing sources. The subscriber’s publishing sources will consist of one of the following combinations:

  1. Two or more publications inside the same publisher database at the same publishing server instance.
  2. Two or more publications in two or more publisher databases at the same publishing server instance.
  3. Two or more publications in two or more publisher databases at different publishing server instances.

Practical examples for these topologies are:

  1. The publisher database contains more published tables than would fit into a single publication. Or you may group published tables into several publications for administrative reasons, e.g. to be able to reinitialize only a subset of the published tables.
  2. You want to consolidate the data from several databases on the same SQL Server instance into a single subscriber database.
  3. You want to consolidate the data from several SQL Server instances into a single subscriber database.

SQL Server will allow you to configure such a topology, because there is no good way to check for the conditions when creating the subscriptions. In most cases, it will work directly after setting it up, and you actually might never have a problem later on.

The inherent problems with this kind of topology usually start to surface if you want to change some aspects of it, like removing and re-adding articles, subscriptions, or publications. This might become necessary after some system failure or accident, or if you need to change the publications or subscriptions to address application design improvements.

 Merge Replication Design Considerations

Merge Replication had been designed to deliver the following feature set:

  • Resilient environment. You may restore a publisher or subscriber database to an older backup, and still experience only minimal or no data loss.
  • Allow for subscribers that remain disconnected for some time.
  • Allow for subscribers on different database types, like SQL Server, SQL Server Compact, or even Microsoft Access (Jet) databases.
  • Provide detailed conflict resolution strategies, based on subscriber priorities down to the column level of the published tables.
  • Create complex scale-out topologies, e.g. Republishing servers spread over distributed regions in order to bring the data closer to the users.

The typical scenario to be addressed by Merge replication was the disconnected sales person, who would be synchronizing on-demand without a specific schedule. The Central Subscribers feature was never on the design list, and therefore wasn’t reflected in the initial implementation. It was also never properly tested

 The first version of SQL Server Merge replication had been released with SQL Server 7.0 back in 1998. It has received major feature upgrades in SQL Server 2000 and 2005, and has further evolved to SQL Server 2012. The core metadata tables have remained practically unchanged though throughout the versions.

 Synchronization of metadata

The Merge Replication metadata of each replica database is stored in a single set of metadata tables. If several subscriptions are created in the same database, the metadata of all subscriptions will be stored in the same set of system tables. The replication metadata is therefore shared by multiple merge agents, all reading and writing from/to the same system tables.

Each time a merge agent synchronizes the publisher with the subscriber database, it will synchronize publication and subscription information between their configured synchronization partners. For example, rows from the subscriber’s sysmergesubscriptions system table are uploaded to the publisher, the publisher’s rows are downloaded to the subscriber. This is necessary for the conflict handling in Republishing topologies: the main publisher and each republisher needs to know about each node in the topology, in order to resolve conflicts according to the replica priorities you had configured. If a new republisher or subscriber is added on one branch of the topology, the metadata for it needs to be uploaded to the main publisher first before it can be downloaded into the other branches.

And it has to be done on each synchronization: if for example you have to restore a node from an older backup, the node will always receive current information from their synchronization partners.

So what’s the problem then?

If you have configured a central subscriber topology, you will have two or more merge agents synchronizing the subscriber metadata with its publisher partners. The potential disaster comes from the fact that each merge agent exchanges not only the metadata for its own publication and subscription, but also for the unrelated other publications and subscriptions.

If e.g. you drop a subscription, the metadata information will be removed immediately from the publisher and the subscriber, but not from the other replicas in the topology. In a central subscriber scenario, if the other merge agents at that subscriber synchronize with their partners, they will re-introduce the outdated subscription information back into replicas, and may remove the information about the deleted subscription at their partner. Because of the disconnected nature of the subscribers, the incorrect metadata might start to oscillate through the topology.

Another aspect is related to running several merge agents in parallel, servicing the same subscriber database at the same time. The potential issues usually start to show if the topology reaches a certain size and complexity. Contributing factors could be the number of publishers and subscribers, the number of data partitions for dynamic filters, the amount of metadata stored in the change tracking system tables, and the complexity of the dynamic filter design.

We have seen support cases with specific symptoms, where the only common denominator were the central subscribers. It included scalability problems due to blocking, or due to the way how the change evaluation is handled, or unexpected conflicts and retries. These issues are typically impossible to reproduce in a test environment, because in most cases you can’t duplicate the complexity and timing of your production environment. So you usually can’t scientifically prove that the central subscriber is the root cause. But you still may see that tweaking the agent schedules or removing the central subscribers from the topology can
lessen or avoid those issues.

 The resulting issues might be unpredictable, intermittent, and unexpected. They may appear at a much later time than the step that actually caused the symptom.

 Two Examples

The following examples are the simplest and most obvious ways to demonstrate metadata issues resulting from a central subscriber topology. The first would also cause direct errors, as they are documented in article KB 2750005. Variations of these steps may lead to other symptoms or subtle differences.

 Example 1: Publications in separate publication databases are synchronizing into the same subscriber database

Consider the following configuration and steps:

  • The initial topology consists of Publication PUB1, internally identified by the publication ID GUID1, and Publication PUB2, identified by the publication ID GUID2. PUB1 and PUB2 exist in two separate publisher databases, either on the same or different publication servers. This topology usually works well immediately after configuration.
  • Both publications replicate into the same subscriber database.
  • Because of some accident or a design consideration, you need to drop PUB1 and its subscription. You re-create the publication again with the same name PUB1; it will receive a new internal identifier GUID3. You also create a new subscription into the existing subscriber database.
  • At this stage, the combination of PUB1/GUID3 is known at publisher database 1 and the subscriber. At publisher database 2, the old combination PUB1/GUID1 is still known if the merge agent hasn’t synchronized already.
  • The merge agent for PUB2 synchronizes. It uploads the information about PUB1/GUID3 to its publisher PUB2, and downloads the information about PUB1/GUID1 into the subscriber database.
  • If PUB2 has further subscriptions, it will distribute the PUB1/GUID3 information into its sub-topology, and receive the PUB1/GUID1 during each of these synchronizations.
  • The merge agent for PUB1 synchronizes. It detects the mismatch between PUB1/GUID3 at the publisher and PUB1/GUID1 at the subscriber. It reports an error pointing to invalid subscription information, or that the publication had been replaced with a new one.

After reaching this point, your topology has been compromised. The incorrect PUB1/GUID1 combination will continue to oscillate through the system, and there is no practical way to get this subscriber back into the topology.

 Example 2: Two or more publications in the same publisher database are synchronizing into the same subscriber database

Consider the following configuration and steps:

  • The initial topology consists of Publication PUB1, identified by the publication ID GUID1, and Publication PUB2, identified by the publication ID GUID2. Both coexist in the same publication database on the same publisher server. This usually works well immediately after configuration.
  • Both publications replicate into the same subscriber database SUB1, and into other subscriber databases SUB2…SUBn.
  • Because of some accident or design consideration, you need to drop PUB1 and its subscription. You re-create the publication again with the same name PUB1; it will receive a new internal identifier GUID3.
  • You create a new subscription into the existing subscriber database SUB1.
  • At this stage, the combination of PUB1/GUID3 is known at publisher and the subscriber database SUB1. At subscriber databases SUB2, the old combination PUB1/GUID1 is still known if the merge agent hasn’t synchronized already.
  • The merge agent for PUB2 synchronizes with SUB2. It uploads the information about PUB1/GUID1 to the publisher database, and downloads the information about PUB1/GUID3 into the subscriber database.

After reaching this point, your topology maintains information about PUB1/GUID1 and PUB1/GUID3. This doesn’t present an immediate issue, as the orphaned old metadata and the current new metadata appear to be able coexist. If the steps are repeated in large topologies, the metadata tables will be bloated unnecessarily. The effects on Republishing topologies haven’t been fully understood because of the increasing complexity of the agent interactions.

 

Conclusion

A central subscriber might work for you immediately after configuring the topology. It might continue to work, as long as you can avoid applying changes to your topology, like removing and re-adding articles, subscriptions, or publications.

But if you get into issues that are related to the central subscriber topology, there is nothing that may help you except for dropping the entire topology and starting over from scratch. This usually implies a major administrative challenge, especially if you need to recover from a failure in an emergency situation.

Regarding enhancing Merge replication to make central subscribers a supported scenario: This would require a major redesign of the core of Merge replication and the way how the metadata is stored and handled. It would effectively mean the development of a completely new type of replication. If you take into account that Merge replication has evolved over several versions of SQL Servers, starting with SQL Server 7.0 back
in 1998, you may see that this just wouldn’t be a simple step in the next Cumulative Update or Service Pack.

 So the strong recommendation is to avoid central subscriber topologies in Merge Replication, and choose a different configuration instead. An alternate solution could be a single central merge publication that provides data partitions based on a parameterized row filter for the individual subscriber databases. Or use transactional replication instead of merge replication, if you really have to rely on this type of topology.

 References:

Article KB 2750005 in the KnowledgeBase:
Merge replication does not support centralized subscriber topologies

Books Online for SQL Server 2012:
Publish Data and Database Objects
http://msdn.microsoft.com/en-us/library/ms152559.aspx
(Note: Refer to the topic “Considerations for Publishing” - "Publishing Tables in More Than One Publication" in this article.

Books Online for SQL Server 2008 R2:
Integrating Data from Multiple Sites (Client)
http://msdn.microsoft.com/en-us/library/ms151790(v=sql.105).aspx
(Note: Refer to the topic “The type of replication to use for this scenario” in this article)

Struggling with unit tests (again)

$
0
0

I am having a mental hard time today because of unit tests. Not tests that fail... tests that don't exist. And tests I’m not sure that should exist.

It is very natural, right, and highly necessary to test methods which do a non-trivial transformation of data. Here is an example: given a list of events, output a list of the timespans between the events, excluding empty timespans.

The implementation of this method will do conditional tests, looping, and handle edge cases in the input such as an empty or single-item list. It not only feels right to test such code, it is also very, very easy to actually test such code as long as you do the appropriate factoring - so that test code can supply/mock out dependencies.

In my scenario this feels like mostly testing the implementation of the system. It is not a true end-to-end scenario, and while it helps satisfy some requirement of the system, and verifying its logic helps provide reassurance that the system overall meets its requirements, it isn’t meeting a requirement per se.

However, there’s a couple weird things I noticed while thinking about this.

I ended up writing and rewriting code a bit so that this code was easily testable, and found that I introduced new data classes that capture more specifically the input/output required of this particular piece of code. Which meant I wrote a little bit of glue code that runs before and after to squeeze data into the exact right shape to easily process, and then resqueeze it into a final output format.

I have the following doubts about what I just did:

· That glue code on the input side shouldn’t really be necessary – I should be able to get or process the input data in the exact right form in the first place

· That glue code on the output side is somewhat necessary, because it also has other functionality - it’s merging yet more data together adding them to the timespans, as it simultaneously puts things into a slightly different format required by another system. However, this could have been done without as many types into the picture, if I was generating the output type from the code under test.

· What I actually built was a pipeline – reformat data, process data, reformat data yet again, merge in more data. The goodness parts of my code, the bits of the application that MUST survive in some form no matter how I refactor it, and probably the best bits to test are the actual changes to the data that happen, not the ‘data contracts’ or ‘schemas of data’ in between those pieces of pipeline.

Where am I going with this? Testing the trivial reformatting of data from one input form to another intermediate form doesn’t feel that valuable. Testing more trivial reformatting of data from a second intermediate form to the final output form also doesn’t feel valuable. Yes there can be bugs in this code. But we’re testing something that doesn’t matter to the customer. It’s better to avoid writing such a test if you can write a test of the same code that also proves something that does matter to the customer.

Actually… the input form and output format of the data don’t actually matter to the customer. They are just conventions of code for dealing with a database and some another service… what matters is that actual data flows through the system.

OK. And now to the second part of my dilemma… I also have a manager asking me if I can get 100% code coverage and OK, if not, why not 80%?

So I feel caught in a pinch between two basic issues: 1) it is necessary to prove every single piece of my code is correct 2) most of my code is so arbitrary, that testing it can’t be said to provide end user value. In fact if done in the wrong way it will provide negative value, since it slows down my ability to change arbitrary code into different arbitrary code that solves some new issue.

How do I get out of this pickle?

Here is my initial idea of how to move forward:

1. write my first tests of some code I know matters

2. measure code coverage, and try to find some more code that isn’t covered at all, but definitely matters to final correctness

3. refactor that code to make it a testable independent piece that can, once tested survive unchanged forever – adding some glue code if necessary

4. figure out some way to remove the glue code? Or write some very stupid throwaway tests that prove this code is correct right now, but the test should probably be deleted as soon as the test fails.

I’ll let you know if that experiment turns up anything interesting…

Matrice de comparaison de ConfigMgr 2012 R2 seul ou avec Windows Intune

$
0
0

Une matrice de comparaison des fonctions couvertes par System Center 2012 R2 configuration Manager (ConfigMgr 2012 R2) avec Windows Intune seul ou en combinaison des deux logiciels est disponible à l’emplacement suivant :
http://technet.microsoft.com/en-us/library/dn600286.aspx

L’article n’est pas, à ce jour, disponible en français, mais reste suffisamment explicite.

Vous y trouverez tant des informations sur les plates-formes Windows RT que Apple Macintosh ou Linux, ainsi que les téléphones et autres tablettes sous iOS ou Androïd.

Vous y trouverez également les couvertures fonctionnelles quand bien même quelques explications seraient nécessaires en appel de note sur des fonctions telles que l’installation de système d’exploitation qui n’est pas possible sur l’ensembles des environnements cités.

Cumulative Update (CU) - Fevereiro de 2014

$
0
0

Salve, salve, pessoas.

Foi anunciado a pouco no Microsoft Project Support Blog pelo Brian Smith o lançamento do Cumulative Update (CU) do mês de Fevereiro de 2014 para os produtos da versão 2010. Lembrando que este CU, assim como todos os CUs desde Agosto de 2012, tem como pré-requisito o Service Pack 1.

A Microsoft recomenda fortemente que você faça os devidos testes em um ambiente de Homologação baseado no seu ambiente de Produção antes de colocar estas atualizações em produção.

Server Rollup Package (Recomendado):

Descrição do Project Server 2010 cumulative update package (Project server-package) - 11 de Fevereiro de 2014: http://support.microsoft.com/kb/2863917.

Como o Project Server 2010 é baseado no SharePointServer 2010, é altamente recomentado que você faça a atualização através deste pacote que inclui todos os patches lançados para o SharePoint Foundation 2010, SharePoint Server 2010 e o Project Server 2010.

 

Individual Project Server Package:

Utilizado apenas se você não utilizou o Server Rollup. Apesar de individual, ele ainda é cumulativo, porém somente para as atualizações do Project Server.

Descrição do Project Server 2010 hotfix package (Pjsrvwfe-x-none.msp) - 11 de Fevereiro de 2014: http://support.microsoft.com/kb/2863927

Descrição do Project Server 2010 hotfix package (Pjsrvwfe-x-none.msp; Pjsrvmui-<Language-Code>.msp) - 11 de Fevereiro de 2014: http://support.microsoft.com/kb/2863934

As bases de dados do Project Server serão atualizadas para a versão 14.0.7115.5000.

 

Project 2010 Client Package:

Descrição do Project 2010 hotfix package (Project-x-none.msp) - 11 de Fevereiro de 2014: http://support.microsoft.com/kb/2863931

O número da versão do cliente é 14.0.7117.5002, no caso de você querer limitar a conexão de certos patches lançados para o Project Server 2010.

 

Service Pack 1:

Como o service pack 1 é pré-requisito para a instalação destes CUs, seguem os links para download:

SP1 para Project Server 2010: http://www.microsoft.com/en-us/download/details.aspx?displaylang=en&id=26636

SP1 para Project Professional 2010 cliente: http://www.microsoft.com/en-us/download/details.aspx?id=26635 (32-bits) e http://www.microsoft.com/en-us/download/details.aspx?id=26627 (64-bit).

 

Ressaltando que a Microsoft recomenda que se faça os testes em um ambiente de homologação antes de fazer o rollout no ambiente de produção.

 

Espero que tenham gostado. Deixe seus comentários e sugestões.

Forte abraço,
Paulo de Oliveira Jr.

 

 


Per request lifetime management for UserManager class in ASP.NET Identity

$
0
0

Introduction

We recently released the 2.0.0-beta1 version of ASP.NET Identity. Learn more here by visiting this link. This is an update to 2.0.0-alpha1 and adds the two-factor auth feature along with a few bug fixes. To learn more about the Alpha release, please visit this link.

In this article I am going to explain the significance of the UserManager class in an application and some of the best practices when using it. I am going to use an MVC application that is created using VS 2013 RTM. In the Visual Studio 2013 RTM templates, which had the 1.0.0 version of ASP.NET Identity, we demonstrated directly instantiating the UserManager class as needed in the application. This approach had a few issues, which are explained further in this article. These have been fixed in 2.0.0-beta1.

Understanding Managers and Stores

ASP.NET Identity consists of classes called managers and stores. Managers are high-level classes which an application developer uses to perform operations in the ASP.NET Identity system, such as creating a user. Stores are lower-level classes that specify how entities, such as users and roles, are persisted. Stores are closely coupled with the persistence mechanism, but managers are decoupled from stores which means you can replace the persistence mechanism without disrupting the entire application.

The current article outlines the steps to configure the UserManager in the application. We will start with an application with Identity 1.0.0. We will migrate the solution to 2.0.0-beta1, and change the way UserManager is instantiated and used in the application. Additionally, with this approach it is possible to configure the properties on the UserManager, such as password length and complexity.

Create Application

In Visual Studio 2013 RTM create a new web application. Choose MVC

clip_image002

UserManager explained

Let us briefly look at how the UserManager class is used in the application. All user account management actions are defined in the AccountController class.

Code Snippet
  1. public AccountController()
  2.             : this(newUserManager<ApplicationUser>(newUserStore<ApplicationUser>(newApplicationDbContext())))
  3.         {
  4.         }
  5.  
  6.         public AccountController(UserManager<ApplicationUser> userManager)
  7.         {
  8.             UserManager = userManager;
  9.         }
  10.  
  11.         publicUserManager<ApplicationUser> UserManager { get; privateset; }

The controller has a UserManager property of type UserManager which is set in the constructor. The UserManager class takes in an instance of UserStore class which implements operations on the user that are persistence-specific. In our case, we have a UserStore class which implements these operations specific to EntityFramework. To persist data to/from the database the UserStore class takes in an instance of DBContext class. The UserStore class is defined in the Microsoft.AspNet.Identity.EntityFramework assembly.

Note: The rationale behind implementing this pattern is that if the developer wishes to store user information in the any other storage system (for example, Azure Table storage), all they have do is replace the ‘UserStore’ class with an Azure Table storage implementation. There would be no additional changes needed in the AccountController, and the existing application would function seamlessly.

The problem

In the current approach, if there are two instances of the UserManager in the request that work on the same user, they would be working with two different instances of the user object. An example for this would be using the one in the class property and instantiating one locally in the method under execution. In this scenario the changes made by either of them would not reflect the changes made by the other. Hence persisting these changes back to the database would lead to incorrect changes being made to the user object.

The same problem exists when you are trying to use the DBContext class in the application.

The solution

The solution to the above problem is to store a single instance of UserManager and DbContext per request and reuse them throughout the application. Since Identity hooks into the OWIN pipeline via cookie middleware, we can store the UserManager and DbContext in the OWIN context object and retrieve them as needed.

1. In the application created above, update the Identity packages to 2.0.0-beta1 from the NuGet feed. This can be done through the Manage Nuget packages window. The steps to update Nuget packages are explained here.

2. Instead of directly working with UserManager<T> class we can define a custom class, ApplicationUserManager that extends from UserManager<T>. In the project under the App_Start folder create a new file IdentityConfig.cs and add a new class ApplicationUserManager. The ApplicationUserManager should extend the UserManager class

Code Snippet
  1. publicclassApplicationUserManager : UserManager<ApplicationUser>
  2.     {
  3.     }

3. The web application uses the new OWIN cookie middleware for the cookie-based authentication. During application start, the Configuration method in the Startup class is invoked, which configures all the middleware components registered in the application. In the MVC 5 template, the cookie middleware is configured through the ConfigAuth method defined in the Startup.Auth class.

Since we need to register the UserManager and DBContext class with the OWIN context during app start, we will add methods to do that in the ConfigureAuth method. The ‘CreatePerOwinContext<T>’ method is defined in the Microsoft.AspNet.Identity.Owin namespace. This method registers a static callback method which returns an instance of type <T>. This method is invoked once per request and used to obtain instance object which is used during the lifetime of the request.

4. To create a static callback method that returns an instance of DbContext , in the ApplicationDbContext class create a method as defined below

Code Snippet
  1. publicstatic ApplicationDbContext Create()
  2.     {
  3.         returnnew ApplicationDbContext();
  4.     }

5. Similarly define a method in the ApplicationUserManager that returns an instance of the ApplicationUserManager.

Code Snippet
  1. publicstaticApplicationUserManager Create(IdentityFactoryOptions<ApplicationUserManager> options, IOwinContext context)
  2.         {
  3.             var manager = newApplicationUserManager(new UserStore<ApplicationUser>(context.Get<ApplicationDbContext>()));
  4.             return manager;
  5.         }

In the constructor of the UserManager, we need to retrieve the instance of DbContext to configure the UserStore. We can get the instance of the object from the OwinContext using the ‘Get<ApplicationDbContext>’ method that in turn returns the single instance of DbContext class created using ApplicationDbContext.Create callback method.

6. Register these two callback methods in the ConfigureAuth method through the ‘CreatePerOwinContext’ method

Code Snippet
  1. publicvoid ConfigureAuth(IAppBuilder app)
  2.         {
  3.         app.CreatePerOwinContext<ApplicationDbContext>(ApplicationDbContext.Create);
  4.         app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.Create);
  5.          .
  6.          }

7. Next we hook this up in the AccountController class. Change the constructor and the UserManager property on the class to type ApplicationUserManager

Code Snippet
  1. public AccountController()
  2.         {
  3.         }
  4.         public AccountController(ApplicationUserManager userManager)
  5.         {
  6.             UserManager = userManager;
  7.         }
  8.         privateApplicationUserManager _userManager;
  9.         publicApplicationUserManager UserManager
  10.         {
  11.             get;
  12.             privateset;
  13.         }

8. In the set property of the UserManager we need can retrieve the UserManager instance from the OWIN context. For this we have an extension method provided in the Microsoft.AspNet.Identity.Owin namespace

Code Snippet
  1. publicApplicationUserManager UserManager
  2.         {
  3.             get
  4.             {
  5.                 return _userManager ?? HttpContext.GetOwinContext().GetUserManager<ApplicationUserManager>();
  6.             }
  7.             privateset
  8.             {
  9.                 _userManager = value;
  10.             }
  11.         }

9. Run the application and verify that a local user can be created in the application.

10. Also in the application if we need to work with the DbContext object directly we can get the instance of the class from the OWIN context as mentioned earlier using the ‘Get<T>’ method

Code Snippet
  1. var dbContext = context.Get<ApplicationDbContext>();

Configuring UserManager properties

Another advantage of following this approach is that we can configure the UserManager properties when instantiating it in a single place. For example, the UserManager by default has a password validator that validates that the supplied password is of length 6 characters. We can change this to use the new password validator in 2.0.0-beta1 which checks for additional complexity in the supplied password during registration.

To do this, simply set the PasswordValidator property in the ‘Create’ method of the ApplicationUserManager with the new ‘PasswordValidator’ class

Code Snippet
  1. public ApplicationUserManager(UserStore<ApplicationUser> userStore)
  2.             : base(userStore)
  3.         {
  4.         }
  5.         publicstaticApplicationUserManager Create(IdentityFactoryOptions<ApplicationUserManager> options, IOwinContext context)
  6.         {
  7.             var manager = newApplicationUserManager(newUserStore<ApplicationUser>(context.Get<ApplicationDbContext>()));
  8.             manager.PasswordValidator = newPasswordValidator
  9.             {
  10.                 RequiredLength = 10,
  11.                 RequireNonLetterOrDigit = true,
  12.                 RequireDigit = true,
  13.                 RequireLowercase = false,
  14.                 RequireUppercase = false,
  15.             };
  16.             return manager;
  17.         }

Here the PasswordValidator class is configured to verify that the supplied password has a non-alphanumeric character and a numeric character. Also the length of password should be of 10 characters length. Similarly other properties of the UserManager can be configured to be persisted through the context lifecycle.

Summary

This post shows how to get a per-request, single instance of the UserManager and DbContext classes from the OWIN context to be used throughout the application. This will form a base for additional blog posts outlining the new features in ASP.NET Identity 2.0.0-beta1.

I hope you have found this walkthrough useful. If you have any questions around ASP.NET Identity or find issues, please feel free to open bugs on the Identity Codeplex site, https://aspnetidentity.codeplex.com/ , leave comments on this blog, or ask questions or StackOverflow (tag: aspnet-identity). I can also be reached on twitter (@suhasbjoshi).


Silicon Valley VS2013 Launch Event - Tues 2/25/2014

Presenting at Sacramento .NET Users Group. See What's New in VS 2013.

$
0
0

What

    A Lap Around What's New in Visual Studio 2013

    With Jason Singh

When

      Wed Feb 26th starting 6pm

Where

Rancho Cordova Library
9845 Folsom Blvd. , Rancho Cordova, CA 95827

 

Registration and details.

http://sacnetug.org/Event/Index/1

 

 

Dynamics CRM Online 多要素認証

$
0
0

みなさん、こんにちは。

先日 Office 365 で、多要素認証機能が特定のサブスクリプションに
ついて無償で提供されることが決まりました。詳細は以下の記事を
ご参照ください。これまで有償でしか利用できなかった多要素認証が
条件によっては無償で利用できることは非常に大きいと感じます。

Office 365 でエンドユーザーの皆様に多要素認証がご利用いただけるようになりました

Microsoft Dynamics CRM Online でも同様に機能しますので是非
お試しください。設定方法は上記リンクに詳細がございます。

※注意点
現時点で多要素認証はブラウザにのみ対応しています。そのため
Outlook クライアントのようなリッチクライアントは対応しません。

多要素認証はセキュリティを向上させるうえで非常に重要な要素で
あると同時に、ユーザーにとってはログインの工数が増えることに
なります。また Outlook クライアントでは利用できないという問題
もありますので、まずは特定のユーザーでお試しいただくことを
推奨します。

- 中村 憲一郎

Barracuda Firewall を使用して Azure アプリケーションをセットアップ/保護する方法

$
0
0

このポストは、1 月 28 日に Ashwin Palekarが投稿した How to Setup and Protect an Azure Application with a Barracuda Firewallの翻訳です。

編集メモ: 今回は、シニア アプリケーション開発マネージャーを務める Tim Omta の投稿をご紹介します。

1 はじめに

Windows Azure でアプリケーションをホストする企業は、どこかの時点で、商業的に活用する目的でアプリケーションをインターネット上に公開する必要があります。インターネットへの公開は、顧客と攻撃者の両方の興味を引きつけることになり、アプリケーション内のデータの価値が上がるにつれ、攻撃者にとってそのアプリケーションの魅力はさらに高まっていきます。企業は、Azure で Web アプリケーションをホストすることによって得られる経済的メリットについては把握していますが、顧客に有益なエクスペリエンスを提供しつつ攻撃者からデータを保護するということに関しては、不安を抱いています。オンプレミスのデータセンターに関しては、攻撃者からアプリケーションを保護するためのインターネット エッジ デバイスが多数存在します。今日では、こうしたデバイスを製造するメーカーの何社かが、Windows Azure をはじめとするホスティング プロバイダー向けのソリューションの提供を開始しています。

Barracuda Networks はその 1 社であり、Windows Azure 向けに Web Application Firewall 仮想デバイスを開発しました。このデバイスでは、Azure IaaS Web サーバーや PaaS Web ロールを保護することが可能です。この記事では、シンプルな PaaS アプリケーションのセットアップ方法を段階的に説明しながら、Barracuda が提供する Windows Azure 向けネットワーク セキュリティ ソリューションについてご紹介していきます。ここでは主に以下の重要な項目についてご紹介します。

  • ネットワークのセットアップ
  • Azure PaaS アプリケーション
  • Barracuda Web Application Firewall (WAF) のセットアップ
  • アプリケーションの公開

このガイドでは、以下の構成図に示すようなシステムを作成します。

2 ネットワークのセットアップ

最初に行うのはネットワークのセットアップです。ネットワークは、Azure 内で PaaS アプリケーション、Web Application Firewall (WAF)、インターネットを接続するにあたっての基礎となります。後から変更することはできないため、ここでは慎重な判断が必要とされます。まず、1 つのネットワーク、その中に 2 つのサブネット、さらに 1 つのアフィニティ グループを作成していきます。ネットワークは、全リソースが参照する IP アドレスの総合プールとなります。また、2 つのサブネットには、Subnet-1 と Subnet-2 という名前を付けます。Subnet-1 は WAF サブネットとなり、WAF のみを含みます。Subnet-2 はアプリケーション サブネットとなり、アプリケーション PaaS ロールのみを含みます。このようにサブネットを区別する理由は、通信するリソースのタイプを、そのアドレスによって把握できるようにするためです。また、区別することによって、各タイプのリソースのセキュリティをサブネットごとに確保できるようになります (サブネットは基本的にリソース タイプでグループ化するため、グループを適切に扱うことができます)。サブネットは、セキュリティとアドレス割り当ての境界を規定します。

最後に、アフィニティ グループを作成することにより、すべてのマシンと新規に作成されたネットワークとをグループ化するように、Azure に通知することができます。また、アフィニティ グループは、通信の待機時間 (レイテンシ) を短縮するためにリソースを地理的に併置します。

2.1 ネットワークとアフィニティグループを作成する

まず、Azure 管理ポータル (http://manage.windowsazure.com/) にサインインします。

左側のウィンドウから [NETWORKS] をクリックします。

ページ上部中央の [VIRTUAL NETWORKS] をクリックします。

左下部にある [NEW] をクリックします。

[NETWORK SERVICES] をクリックします。

[VIRTUAL NETWORK] をクリックします。

[CUSTOM CREATE] をクリックします。

このダイアログで、慎重に名前を選択するようにします。以降、このインフラストラクチャ全体を通じてこのネットワーク名とアフィニティ グループ名を使用することになるため、後からこれらを変更することは推奨されません (変更するとすべて台無しになります)。

[NAME] テキスト ボックスにネットワーク名を入力します。

[AFFINITY GROUP] で「Create a new affinity group」が選択されていることを確認します。

ネットワークを作成し、リソースを地理的に配置するリージョンを選択します。

アフィニティ グループの名前を入力します。

[OK] をクリックします。

2.2 ネットワークアドレスとサブネットアドレスの範囲を決定する

次に、下の画像のようなページが表示されます。

ネットワークのアドレス空間を選択します。ここでは「172.16.x.x」という全体的なネットワーク アドレス範囲を選択したため、最初の 2 つのドット付き数字 (オクテット) は、このネットワーク上のすべてに共通して使用されます。「172.16.1.0/16」は、IP アドレスの割り当てを「172.16.1.0」から開始するつもりであり、最後の 16 ビット (最下位の 2 つのオクテット) をアドレスとして変化させるということを Azure に通知します。最下位の 2 つのオクテットを、それぞれサブネット番号とデバイス アドレスとして使用します。

[ADDRESS SPACE] に「172.16.1.0/16」と入力します。

「172.16.1.0/24」のアドレス空間に「Subnet-1」という名前のサブネットを追加します。

「172.16.2.0/24」のアドレス空間に「Subnet-2」という名前のサブネットを追加します。

ネットワークは、以下の画像のとおりに作成され、ポータルに表示されます。

以上で、Subnet-1 に WAF を配置し、Subnet-2 にアプリケーションを配置するための準備ができました。

次に、保護対象となるアプリケーションの作成と構成を行います。

3 Azure PaaS アプリケーション

このステップでは、アプリケーションを作成し、Paas Web ロールにそのアプリケーションをデプロイします。ここで重要なのは、アプリケーションそのものではなく、アプリケーションの構成になります。構成は、WAF で保護するすべての Web ロールに対して行う必要があります。また、この構成は、ここまでの手順で作成したネットワーク レイアウトが準備されていることを前提としています。ネットワーク名、アフィニティ グループ、サブネット名は、アプリケーションの構成に不可欠です。デプロイされたアプリケーションはインターネットからのトラフィックを直接受け取ることはできず、自身のサブネット (Subnet-2、アプリケーション サブネット) と WAF サブネット (Subnet-1、WAF サブネット) 上のロールとのみ通信できます。

3.1 デモ アプリケーションを作成する

Visual Studio で、[File] メニューを開き、[New] を選択して、[Project] をクリックします。

左側のウィンドウで [Cloud] を選択します。

中央のウィンドウで [Windows Azure Cloud Service] テンプレートをクリックします。

プロジェクトの名前を入力するか、既定の名前 (WindowsAzure1) をそのまま使用します。ここでは「DemoApp」という名前を付けたので、これ以降、この名前がアプリケーション名として表示されます。

[OK] をクリックします。

次のダイアログで、[ASP.NET Web Role] をクリックします。

[>] ボタンをクリックして、この Web ロールを追加します。

[OK] をクリックします。

Default.aspx を開いて、<h2> タグ コンテンツを以下のように変更します。

変更前: Modify this template to jump-start your ASP.NET application

から

変更後: This application is protected by the Barracuda Web Application Firewall

ここまでの手順で、標準の Azure Web ロール アプリケーションが作成されました。以降の修正は、Azure の WAF の背後に配置する必要があるすべてのアプリケーションに対して行うべき重要な修正です。

3.2 アプリケーションを構成する

まずアプリケーションの構成を変更して、それをネットワークのアプリケーション サブネット (Subnet-2) に配置します。

Visual Studio クラウド プロジェクトで、ServiceConfiguration.Cloud.cscfg ファイルを開きます。

下の図に示すように、ServiceConfiguration タグ内に次の NetworkConfigurationセクションを追加します。Role の終了タグの直後に追加できます。

<NetworkConfiguration>

<VirtualNetworkSitename="DemoVNet"/>

<AddressAssignments>

<InstanceAddressroleName="WebRole1">

<Subnets>

<Subnetname="Subnet-2"/>

</Subnets>

</InstanceAddress>

</AddressAssignments>

</NetworkConfiguration>

ネットワーク名に VirtualNetworkingSite の名前属性を割り当てます。先ほど付けたものと同じ名前を使用している場合、ネットワーク名は「DemoVNet」となります。

既にこのファイルにある Role タグの名前属性と同じ値に InstanceAddress タグの roleName 属性を割り当てます。

さきほど作成し、アプリケーション サブネットの「Subnet-2」として指定したサブネットの名前に、Subnet タグの名前属性を割り当てます。

これで ServiceConfiguration.Cloud.cscfg は、以下のようになります。

ファイルを保存します。

3.3 アプリケーションファイアウォールの構成のためにコマンドファイルを追加する

この作業の主な目的は、WAF サブネット (Subnet-1) からのトラフィックを受け入れるために、PaaS ロールのファイアウォールを開放するコードを追加することです。ここでは、netsh (英語)を呼び出すロール起動タスクを使用して、ファイアウォール ルールを追加する方法をご紹介します。これは、他の方法 (ロールの OnStart メソッドでの C# コードなど) でも実現できます。

WebRole1 プロジェクトを右クリックします。

[Add] をクリックします。

[Text File] を選択します。

ファイルに「Start.cmd」という名前を付けます。

[OK] をクリックします。

start.cmd に以下の行を追加します。

eventcreate /ID 1 /L APPLICATION /T INFORMATION /SO demoWebApp /D "Webrole start task complete" netsh firewall add portopening protocol=TCP port=80 name="demoWebApp" mode=ENABLE scope=CUSTOM addresses=172.16.1.0/255.255.255.0 profile=CURRENT

最初の行は、start.cmd が起動したことを示すイベントを Windows Server アプリケーションのイベント ログにポストします。

2 番目の行は、WAF サブネットからのトラフィックのために、Paas Web ロール上で TCP トラフィック用にポート 80 を開放します (前の段階で、172.16.1.x アドレス空間に Subnet-1 を作成しました)。

既定では、Visual Studio は start.cmd を Unicode で保存しますが、cmd コマンド プロセッサはこれを実行できません。cmd が実行されるように、ファイルは確実に ASCII エンコーディングで保存する必要があります。

この設定を行うには、Visual Studio の [File] メニューをクリックして [Advanced Save Options] を選択します。

[encoding] を「US-ASCII – Codepage 20127」に変更します。

[OK] をクリックします。

ソリューション エクスプローラーで start.cmd を選択します。

start.cmd ファイルの [Properties] で、[Build Action] を「None」に設定します。

[Copy to Output Directory] を「Copy Always」に設定します。

start.cmd ファイルを保存します ([File]、[Save] の順にクリック)。

これで、ロールが起動されたときに実行するバッチ ファイルが作成されました。次に、ロールを構成して、インターネット トラフィックを受け入れず、実際に start.cmd ファイルを実行するようにする必要があります。

3.4 アプリケーションエンドポイントと起動タスクを構成する

クラウド プロジェクトで、ServiceDefinition.csdef ファイルを開きます。

InputEndpoint タグを InternalEndpointに変更します。

Endpoints の終了タグの下に、start.cmd を実行する Startupタグを追加します。

<Startup>

<TaskcommandLine="start.cmd" executionContext="elevated" taskType="simple"></Task>

</Startup>

ServiceDefinition.csdef は、以下のようになります。

ファイルを保存します。

3.5 適切なアフィニティグループにアプリケーションのクラウドサービスを追加する

次に、アプリケーションをホストするクラウド サービスをカスタム作成する必要があります。クラウド サービスのカスタム作成によって、ここで作成したネットワークのアプリケーション サブネット (Subnet-2) 内にアプリケーションを配置できることを後で確認するアフィニティ グループを指定できるようにします。

Azure 管理ポータルで、左側のウィンドウにある [CLOUD SERVICES] をクリックします。

左下にある [NEW] をクリックします。

[COMPUTE]、[CLOUD SERVICE] を順に選択します。

[CUSTOM CREATE] をクリックします。

アプリケーション クラウド サービスに、任意の URL を指定します。ここでは、アプリケーションと同じ名前を使用します。

ネットワークの作成時に作成したアフィニティ グループを選択します。この手順は重要です。これによって、ネットワークと同じグループにアプリケーション クラウド サービスを配置できるためです。

OK チェック マークをクリックします。

3.6 アプリケーションを発行する

最後に、カスタム作成したクラウド サービスにアプリケーションを発行します。

Visual Studio で [Cloud Project] を右クリックして、[Publish…] を選択します。

サブスクリプションを選択します。

[Next] をクリックします。

直前に作成したクラウド サービスを選択します。サービスと関連付けたアフィニティ グループが表示されることを確認してください。

RDP やその他の必要な設定を構成します。

[Next] をクリックします。

最後に、以下のような概要が表示されます。

[Publish] をクリックします。

数分後、アプリケーションが Azure に発行され、実行されます。RDP を有効にすると、PaaS ロール インスタンスにログオンしてイベント ログを見ることができます。起動タスクが正しく動作していれば、ロール アプリケーション ログに「Webrole start task complete」というメッセージが表示されます。ここで作成した start.cmd ファイルの詳細を見ると、最初の行がこのイベント メッセージをポストしていることがわかります。また、このロールの Windows Firewall コンソールにリストされたファイアウォール ルールを確認することもできます。このルールは、start.cmd の netsh 行で付けられた名前で表示されます。

アプリケーションが正常に起動し、動作しているので、WAF のセットアップに移ります。

4. WAF のセットアップ

WAF VHD ファイルをお持ちでない場合は、Barracuda Networks から入手する (英語)必要があります。「Barracuda Web Application Firewall Azure Virtual Device」をリクエストしてください。

4.1 Azure ストレージアカウントに Barracuda VHD アップロードする

以下に示すような add-azurevhd (英語) Azure PowerShell コマンドレットを使用することができます。基になる変数は、Barracuda 社のサイトからダウンロードした vhd への完全なパスです。対象になる変数は、ストレージ アカウントの URL、コンテナー、および vhd のアップロード先となるファイル名です。Azure PowerShell コマンドレットのセットアップ手順については、http://msdn.microsoft.com/ja-jp/library/windowsazure/jj156055.aspxを参照してください。

4.2 VHD から仮想マシンディスクを作成する

Azure 管理ポータルで、左側にある [VIRTUAL MACHINES] を選択します。

ページ上部中央の [DISKS] をクリックします。

[CREATE] をクリックします。

次のダイアログで、ディスクに名前を付けます。

[VHD URL] に、アップロードした vhd のパスとファイル名を設定します。

[The VHD contains an operating system] チェック ボックスをオンにします。

オペレーティング システムとして「Linux」を選択します。

チェック マークをクリックします。

これでディスクが作成されます。次のステップでは、ディスクから仮想マシンを作成します。

4.3 IaaS Barracuda 仮想マシンを作成する

ディスクから仮想マシンを作成するには、管理ポータルで [VIRTUAL MACHINES] を選択します。

ページ下部の [NEW] ボタンをクリックします。

[COMPUTE]、[VIRTUAL MACHINE] を順に選択します。

[FROM GALLARY] をクリックします。

次のダイアログで、左側にある [MY DISKS] をクリックします。

右側のリストを一番下までスクロールします。

今作成したディスクをクリックします。

この仮想マシンに名前を付けます。

仮想マシンのサイズを選択します。サイズの選択は、WAF が処理しなければならないトラフィックの量により変わります。サイトのトラフィックが極端に少ないのでなければ、最低でも [Medium] を選択するとよいでしょう。

[Next] 矢印をクリックします。

[CLOUD SERVICE] リスト ボックスで、「Create a new cloud service」を選択します。

クラウド サービスの DNS 名を選択します。

仮想ネットワークを、手順 1 で作成した仮想ネットワーク「DemoVNet」に設定します。

サブネットを、手順 1 で作成した WAF サブネット「Subnet-1」に設定します。

[Next] 矢印をクリックします。

HTTPS エンドポイントを追加することにより、WAF に TCP ポート 443 を開放します。

OK チェック マークをクリックします。

Azure は仮想マシンを作成し、起動します。WAF 仮想マシンの起動までしばらく待つと (30 分程度)、安定した状態になります。仮想マシンの状態は、Azure 管理ポータルの仮想マシン ダッシュボードで確認できます。ダッシュボードで、CPU 使用率の登録が開始されます。

4.4 Barracuda 仮想デバイスをプロビジョニングする

ブラウザーを開いて、WAF 管理ページに移動します。WAF 管理ページの URL は、前のセクションで指定した仮想マシンのクラウド サービスの DNS 名です。ここでは、https://omtaDemoWAF.cloudapp.netとなっています。技術情報として、Barracuda のサイト (http://techlib.barracuda.com/display/BWAFv76/Barracuda%2BWeb%2BApplication%2BFirewall%2BVx%2BQuick%2BStart%2BGuide%2B-%2BWindows%2BAzure、英語) に、起動中は SSL 管理サイトにアクセスできない場合がある旨が掲載されています。このことが問題になる場合は、前のステップで Azure ポータルから作成したクラウド サービスに、エンドポイントとしてポート 8000 を追加し、次にポート 8000 で明白な HTTP (この例では http://omtaDemoWAF.cloudapp.net:8000) の管理サイトにアクセスしてデバイスの状態について確認します。

今回初めて WAF にアクセスしたので、以下の管理ページが表示されます。

Barracuda のライセンス トークンを入力します。

アプリケーションが配置される DNS ドメイン (contoso.net または、任意のドメイン) を入力します。

[Provision] ボタンをクリックします。

ブラウザーを閉じて、WAF のプロビジョニングが完了するまで数分待ちます。WAF は自動的に再起動して、しばらくすると元に戻ります。

これで、次の手順のアプリケーションの発行を行う準備ができました。

5. アプリケーションの公開

最後に、インターネットから WAF 経由でアプリケーションにつながるリンクを作成します。

5.1 WAF 仮想サービスを作成する

ブラウザーを開いて、手順 3 のステップと同様に、WAF 管理ページに移動します。

今回はログイン ページが表示されるため、ここに Barracuda の既定の管理ユーザー名を入力します。

管理ユーザー用の既定のパスワードを入力します。

[Login] ボタンをクリックします。

WAF 管理ポータルにログインし、[BASIC] タブをクリックします。

リボンで [Services] をクリックします。

WAF サービスと、仮想サービスを追加するセクションをリストしたページが表示されます。WAF サービスは、WAF に入ってくるトラフィックと PaaS アプリケーション間のリンクです。PaaS アプリケーションは内部エンドポイント付きで作成されているため、インターネットからファイアウォールで遮断されています。

[Service Name] テキスト ボックスに仮想サービスの名前を入力します。

[Virtual IP Address] テキスト ボックスに WAF の IP アドレスを入力します。WAF は Subnet-1 (WAF サブネット) の最初のデバイスなので、「172.16.1.4」というアドレスになります。Azure のアドレスは DHCP アドレスですが、所定のサブネット内で Azure が提供する最初のアドレスは常にネットワーク範囲の最初から 4 番目のアドレスです。

[Port] テキスト ボックスに「81」と入力します。

[Real Servers] テキスト ボックスに最初の PaaS ロール サーバーの IP アドレスを入力します。このアドレスは「172.16.2.4」になります (Subnet-2 (アプリケーション サブネット) の最初のサーバーであるため)。

[Add] ボタンをクリックします。

ここまでの手順で、WAF に仮想サービスを作成しました。仮想サービスは WAF にポート 81 でインターネットから入ってくるトラフィックを調査し、ポリシーと照合し、これが準拠していればそのトラフィックをポート 80 のバックエンド PaaS アプリケーション サーバーに渡します。ここではポート 81 を選択しましたが、これは、アプリケーションが公開されるものと同じポートを選択する必要がないことを示すためです。仮想サービス用にポート 80 を選ぶこともできますので、ご自身でお試しください。

サービス ページは、以下のようになります。

5.2 WAF 仮想サービスをインターネットに公開する

次に、インターネットから WAF へのトラフィックを許可するように、Azure に通知する必要があります。これには、ポート 81 を WAF クラウド サービスのエンドポイントに追加します。

Azure 管理ポータルで、左側のウィンドウにある [VIRTUAL MACHINES] をクリックします。

WAF 仮想マシン名をクリックします。

ページ上部中央の [ENDPOINTS] をクリックします。

ページ下部中央の [ADD] ボタンをクリックします。

[Add a Stand-Alone Endpoint] を選択します。

[Next] 矢印をクリックします。

[Name] テキスト ボックスに、エンドポイントの名前を入力します。

プロトコルとして「TCP」を選択します。

パブリック ポートを「81」に設定します。

プライベート ポートを「81」に設定します。

チェック マーク ボタンをクリックして、エンドポイントを追加します。

これで、エンドポイントのリストは以下のようになるはずです。これらは��インターネットから WAF 仮想マシンへの通信を Azure が許可するポートです。

この時点で、WAF IaaS マシンをホストするクラウド サービスに付けた DNS 名を使用して、アプリケーションにアクセスすることが可能になっているはすです。このデモでは omtaDemoWAF を使用したので、URL は http://omtaDemoWAF.cloudapp.net:81/default.aspxになります。

これで設定は完了です。

6. 負荷分散とフォールトトレランス

ここまでの手順では、操作の基本を学習しました。次に、フォールト トレラントと負荷分散を実現するシステムを作成するステップに進みます。Barracuda 仮想デバイスをクラスター化して、セクション 5.1 で作成した WAF サービスに複数の PaaS ロールを配置することができます。

この記事の執筆時点では、仮想デバイスのクラスター化に関する資料はリリースされていませんが、物理デバイスの場合に関する情報は、http://techlib.barracuda.com/display/BWAFV76/How+to+Set+Up+a+High+Availability+Environment+with+Two+Barracuda+Web+Application+Firewalls (英語)からご確認いただけます。

この情報のうち、LAN、MGMT、ブリッジ モードに関する記述は無視してください (LAN と MGMT インターフェイスは、仮想デバイス上では同一です)。

セットアップが完了したら、システム間の構成は、複数の WAF ノードのアクティブ/アクティブ クラスターで同期することができます。クラスター内の 1 つのデバイスに加えられた構成の変更は、その構成クラスター内の他の全デバイスに伝達されます。

以下の設定は、クラスター化された WAF 間では伝達されません。クラスター化の時点であらかじめ設定が済んでいない場合は、クラスター内の各 WAF でこれらを手動で構成する必要があります。

  • WAN IP アドレス/ネットマスク/ゲートウェイ
  • システム DNS サーバー
  • システムのホスト名
  • クラスターの共有シークレット
  • システムのタイム ゾーン
  • システム IP/パスワード/シリアル
  • HTTP/HTTPS ポート (全マシン上で同じ値にしなければなりません)
  • HTTPS 証明書/設定
  • アピアランス名、ロゴ、または URL
  • リンク監視設定
  • リモート サポート オプション
  • NIC 速度/二重化設定

PaaS ロールに関しては、セクション 5.1 で最初の PaaS ロールを WAF サービスに追加したのと同じ要領で、他のロールも追加することができます。WAF は REST API を有しているため、このプロセスは自動化できます。PaaS ロールの OnStart メソッドに、起動時にそのロールを WAF サービスに追加するコードを記述することができます。今回の設定では、WAF が特定のサブネットに配置され、また、Azure は常にサブネットのアドレス範囲の 4 番目の IP を最初のデバイスに割り当てるため (この説明では最初の WAF に常に 172.10.1.4 が割り当てられます)、PaaS ロールが最初の WAF を検出して、自らを既知の WAF サービスに追加するように、構成設定を PaaS ロールに追加することができます。

反対に、PaaS ロールの OnStop メソッドに、ロールの終了時に WAF サービスからそのロールを削除するコードを記述することもできます。

説明は以上で終了です。この情報が、皆様のデータ保護とビジネスの拡大に少しでも役立つことを願っています。

Viewing all 35736 articles
Browse latest View live




Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>
<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596344.js" async> </script>