UPDATE: The information in this post is now out of date please see http://blogs.msdn.com/b/windowsazure/archive/2011/07/06/windows-azure-deployments-and-the-virtual-ip-address.aspx 

Recently I have seen a lot of questions asking how Windows Azure allocates IP addresses to services. At this time Windows Azure does not offer the capability to fix an IP address for your service  however there are some scenarios where this can be a  requirement, e.g. some external services require IP addresses of the caller to be pre-configured before allowing traffic to flow (SQL Azure does this) . The information  in this post is designed to help you understand  how IP addresses are allocated in Windows  Azure and what you can do to ensure that they do not change.

Each compute service that is created in windows Azure has two deployment slots , one for production and one for staging, each of these slots has a DNS name and associated IP address. The DNS name associated with the production slot is assigned at the time that the service is created and is fixed for the lifetime of that service, the DNS name for the staging slot is dynamically generated each time a service is deployed .

Each  time a service instance is deployed to one of these slots the DNS name associated with it has an IP address assigned to it from a pool of available addresses. The service slot will then keep that IP address until  the service deployment is deleted. Upgrading your application, altering the configuration or swapping the production and staging slots will not cause the IP address to change.

The same IP address is used for both inbound and outbound traffic.

UPDATE: There have been lots of  questions about this post, one of the most common is if a service can be guaranteed to keep the same IP address by taking account of the information above. The answer is no, at this time there is no way for a service to be guaranteed that its IP address will not change.  Following the information here will ensure that there is less likelihood of a change occurring.