title: tSQL to set up user with View Definition permission on SQL Azure
body: <p>I'm trying to export a SQL Azure database to a <code>.bacpac</code> file using the Azure portal. The administrator <strong>username</strong> on my database contains a <code>*</code>. When I use it in the username field I get this error.</p>
  
  <pre>
  The login name must meet the following requirements:
  It must be a SQL Identifier.
  It cannot be a system name, for example:
  - admin, administrator, sa, root, dbmanager, loginmanager, etc.
  - Built-in database user or role like dbo, guest, public, etc. 
  It cannot contain:
   - White space like spaces, tabs, or returns
   - Unicode characters
   - Nonalphabetic characters ("|:*?\/#&;,%=)
  It cannot begin with:
   - Digits (0 through 9)
   - @, $, +
  </pre>
  
  <p>So I add a new user to the database using the following tSQL.</p>
  
  <pre><code>USE master;
  CREATE LOGIN gu6t6rdb WITH PASSWORD = 'kjucuejcj753jc8j'
  
  USE MyActualDB;
  CREATE USER gu6t6rdb FOR LOGIN gu6t6rdb
  </code></pre>
  
  <p>The portal export form accepts that username but later errors with the following message.</p>
  
  <blockquote>
    <p>Error encountered during the service operation. Could not extract
    package from specified database. The reverse engineering operation
    cannot continue because you do not have View Definition permission on
    the 'MyActualDB' database.</p>
  </blockquote>
  
  <p>To fix this I tried the following tSQL</p>
  
  <pre><code>GRANT VIEW ANY DEFINITION TO gu6t6rdb 
  </code></pre>
  
  <p>which throws the following error</p>
  
  <blockquote>
    <p>Securable class 'server' not supported in this version of SQL Server</p>
  </blockquote>
  
  <p>How should I use tSQL to provide an additional user on my database and give the user sufficient privileges to export the database through the Azure portal to a <code>.bacpac</code> file in an Azure blobstore?</p>